Hi I have had a look at alot of posts on this forum and other throughout the web.
I am trying to get the .htaccess mod rewrite to work on my site.
I was wanting to set it up so that it would create more seo friendly urls from my pages but thought I should try to get something simple working first.
The code I have in my .htaccess file is below:
RewriteEngine on
RewriteRule ^/([a-zA-Z0-9]+)$ $1.php [L]
I thought this should remove all .php file extensions on my site but it doesn’t work!
Can anyone help with this please? I don’t get any errors I’ve cleared the cache on my browser but still nothing. Th e.php file extensions still show!
The .htaccess doesn’t remove the .php from the links in your site, that’s your job to change those yourself in the source. All the .htaccess does is serve /contact.php when /contact is requested for example.
OK I think I might be getting confused with this a little. What I am trying to do is get my site to generate more seo friendly url’s. For example the way the site is currently set up it has links such as:
Right I’m still confused with this. I have read the article you pointed me to did the tests and tried the examples and most of them make sense. I still don’t understand how I can get this to work.
Can you please give me some help with the url’s I posted?
Sorry but I’m just a little confused with this. The article you pointed me to seems to show how to do the opposite of what I’m looking for, which I don’t understand.
Right I’m trying to work this out. In the examples I’ve given for what I’m looking to do should my links look like so:
<a href=‘/BMW/G650/2007/’> more info ></a>
I’m trying to work out why what I have is not working, I think I have the .htaccess set up wrong but can you tell me if what I’ve put here should work when I get the .htaccess file working correctly so I know that the link structure I have is at least right?
ok cool, thanks for that. I’ll keep working on the RewriteRule to see if I can figure this out.
Might be back for some advice in a bit if I can’t get this to work.
I keep getting 404 not found errors on all of those. Should the links I’m getting people to click onto be like this /BMW/G650/2007/ or like this details.php?make=BMW&model=G650&year=2007
The links people click on (the <a href>) should be like /BMW/G650/2007/
Are you sure mod_rewrite is installed and enabled on the server?
You can do a little test. Put this in the .htaccess :
Options +SymLinks
RewriteEngine On
RewriteRule test http://www.google.com/ [L,302]
Then go to a URL on your site that contains “test” (doesn’t matter how or where). If it takes you to google.com mod_rewrite is installed and works, if it doesn’t mod_rewrite is either not installed or disabled.