php - Apache mod rewrite for dynamic pages -
i'm having problem mod rewrite rule wrote website, nothing seems change pages url loading same before, if have @ , let me know if there problems appreciated, thanks!
rewrite rule
rewriteengine on rewriterule ^([^/]*)/$ /index.php?art_id=$1 [l] url
http://www.test.com/index.php?art_slug=test desired result
http://www.test.com/test
enable mod_rewrite , .htaccess through httpd.conf , put code in .htaccess under document_root directory:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / # externally redirect /index.php?art_slug=test /art_slug/test rewritecond %{the_request} ^[a-z]{3,}\s/+/(?:index\.php|)\?([^=]+)=([^\s]+) [nc] rewriterule ^ /%1/%2? [r=302,l] # internally forward /art_slug/test /index.php?art_slug=test rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^([^/]+)/(.+)$ /index.php?$1=$2 [l,qsa] once verify working fine, replace r=302 r=301. avoid using r=301 (permanent redirect) while testing mod_rewrite rules.
Comments
Post a Comment