0

i have problem with rewrite url in .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /web/
RewriteRule ^([^/]*)$ artist.php?artist=$1 [R]

i'm used [R] because i can see that mistake..
if i'm type:
http://localhost/web/djardy but it's redirect to :
http://localhost/web/artist.php?artist=artist.php
it's should be redirect to :
http://localhost/web/artist.php?artist=djardy

and i change the .htaccess code, but still not working..

RewriteEngine On
RewriteRule ^([^/]*)$ artist.php?artist=$1 [R]

thanks ..

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by royalrai_p
0

This should be what you need

RewriteRule ^([a-z0-9-\s]+) artist.php?artist=$1 [L,NC,QSA]

0

Yeah, your CSS won't work properly because the rewrite rule changes the path for requested files. If you're using relative paths this will mess up your CSS, images and JS.

You can either add rewrite rules for all your CSS and media files or you can access them using the full path starting from your webroot.

Instead of

<link rel="stylesheet" type="text/css" href="css/style-admin.css">

Use

<link rel="stylesheet" type="text/css" href="/web/css/style-admin.css">

Or you could write the rewrite rule for your CSS

RewriteRule ^([a-z0-9-\s]+)(\.css) web/css/$1.css

I'm not sure this is the best way (.htaccess is not my strong suite) but it works. Make sure the paths are correct for you.

0

Hi,
What if I want to apply the rewrite rule to all the css files under the root directory.. I mean there can be multiple directories having css files so I cannot put web/css specifically for below:

RewriteRule ^([a-z0-9-\s]+)(\.css) web/css/$1.css

Instead, can <FilesMatch> be used to serve the purpose?

Eg, If I need to apply a rewrite rule to redirect my css file to a php file I write as below:

<FilesMatch "\.css$">
RewriteRule ^([a-z0-9-\s]+)(\.css) web/css/$1.php
</FilesMatch>

0

I am sorry, the last piece of code will be :

<FilesMatch "\.css$">
RewriteRule ([a-z0-9-\s]+)(\.css) $1.php
</FilesMatch>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.