htaccess rewrite not working - Wordpress Solution
[Solved] - htaccess rewrite not working - Wordpress Solution
Try following codes
Hi All, I have a theme that uses a dynamically generated CSS file in PHP where htaccess is then used to rewrite the .css requests to .php. The problem is that it works on my friends server but it doesn't on mine. I've asked the host if mod_rewrite is enabled and they say it is so I'm not sure what the issue is. I can access the file when visiting it with the php extension but the .css produces nothing. How do I debug the problem or fix it? The htaccess file contents are as follows:
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteRule custom.css custom.php [L,QSA]
Many thanks.

Solution - 1

You could try something like this:

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteRule ^custom\.css$ /custom.php [R=302,L]
I used the following to get the above: [[LINK href="http://stackoverflow.com/questions/1668941/how-to-use-rewriterule-to-redirect-to-a-php-file-in-the-same-folder"]]http://stackoverflow.com/questions/1668941/how-to-use-rewriterule-to-redirect-to-a-php-file-in-the-same-folder[[/LINK]]

Solution - 2

You'll need to tell the server that its css add at the very beginning of custom.php

// We'll be outputting a CSS
header('Content-type: text/css');

Date: 2022-10-21 05:14:49
Category: Wordpress
More for You