rewrite rule not working

Reply

Join Date: Mar 2008
Posts: 70
Reputation: forzadraco is an unknown quantity at this point 
Solved Threads: 1
forzadraco forzadraco is offline Offline
Junior Poster in Training

rewrite rule not working

 
0
  #1
Oct 16th, 2009
i have problem with rewrite url in .htaccess


  1. Options +FollowSymLinks
  2. RewriteEngine On
  3. RewriteBase /web/
  4. 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..
  1. RewriteEngine On
  2. RewriteRule ^([^/]*)$ artist.php?artist=$1 [R]

thanks ..
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 102
Reputation: jomanlk is an unknown quantity at this point 
Solved Threads: 18
jomanlk jomanlk is offline Offline
Junior Poster
 
0
  #2
Oct 16th, 2009
This should be what you need

RewriteRule ^([a-z0-9-\s]+) artist.php?artist=$1 [L,NC,QSA]
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 70
Reputation: forzadraco is an unknown quantity at this point 
Solved Threads: 1
forzadraco forzadraco is offline Offline
Junior Poster in Training
 
0
  #3
Oct 20th, 2009
it's still not working, http://localhost/web/ardy redirect to http://localhost/web/artist.php?artist=artist

  1. Options +FollowSymLinks
  2. RewriteEngine On
  3. RewriteBase /
  4. RewriteRule ^([a-z0-9-\s]+) web/artist.php?artist=$1 [R]

and if i used that .htaccess my css site is not working properly..
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 102
Reputation: jomanlk is an unknown quantity at this point 
Solved Threads: 18
jomanlk jomanlk is offline Offline
Junior Poster
 
0
  #4
Oct 22nd, 2009
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
  1. <link rel="stylesheet" type="text/css" href="css/style-admin.css">
Use
  1. <link rel="stylesheet" type="text/css" href="/web/css/style-admin.css">

Or you could write the rewrite rule for your CSS
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: royalrai_p is an unknown quantity at this point 
Solved Threads: 0
royalrai_p royalrai_p is offline Offline
Newbie Poster
 
0
  #5
Nov 13th, 2009
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>
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: royalrai_p is an unknown quantity at this point 
Solved Threads: 0
royalrai_p royalrai_p is offline Offline
Newbie Poster
 
0
  #6
Nov 13th, 2009
I am sorry, the last piece of code will be :

<FilesMatch "\.css$">
RewriteRule ([a-z0-9-\s]+)(\.css) $1.php
</FilesMatch>
Reply With Quote Quick reply to this message  
Reply

Tags
clean, htaccess, mod_rewrite, url

Message:



Similar Threads
Other Threads in the PHP Forum


Views: 875 | Replies: 5
Thread Tools Search this Thread



Tag cloud for clean, htaccess, mod_rewrite, url
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC