aweb Posted December 22, 2009 Share Posted December 22, 2009 I am struggling to get a basic mod_rewrite working with my .htaccess. I will add first that mod_rewrite is enabled on my server, I am uploading .htaccess in ANSI, and I have no problem getting rules such as force www working. My problem is that I cannot get "remove .php from url" to work nor can I can rewrites working for my dynamic urls. Here is what some of my .htaccess looks like: Start: Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / I tried using the following so that, for example, category 13, would be show up: http://www.example.com/newname RewriteCond %{QUERY_STRING} ^id=13$ RewriteRule ^/categories.php$ http://www.example.com/newname [L,R=301] Since I got no response from that above, I tried this: Redirect 301 /categories.php?id=27$ http://www.example.com/ RewriteRule ^new-title$ categories.php?id=27 [nc]] Now, I can point to the url http://www.example.com/new-title and that works fine but for some reason the redirection isn't working... Also while we are at it, this isn't working at all either: ##################################### # Remove file extension and force trailing slash ##################################### RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] Any help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/185953-help-seo-friendly-url-structure-using-htaccess/ Share on other sites More sharing options...
cags Posted December 22, 2009 Share Posted December 22, 2009 RewriteRule ^([^/]+)/$ $1.php What URL are you testing the rule with? This rule will only work if you input http://www.example.com/new-title/ (note the trailing slash). Quote Link to comment https://forums.phpfreaks.com/topic/185953-help-seo-friendly-url-structure-using-htaccess/#findComment-982182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.