First of all, ModRewrite is a blind spot for me, I'm completely clueless when it comes to simplifying URLS, so bear with me.
Right, basically I've inherited a CMS from a colleague of mine which I use quite often. It's开发者_如何学JAVA a great framework and very useful for what I'm doing right now.
My client wants a list of towns on their site, the data of which I've been provided with. I've added them all in and every town is called based on the ID. Simple, yep!
The URL currently looks like town.html?tID=64 but I want it to read something like town/manchester.html
So far, my htaccess looks like:
RewriteEngine On
RewriteRule ^town/([^/]*)-([0-9]+)\.html$ town.html?tID=$2&tN=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
I added the &tN so I could pass the town name through.
Nothing happens though, which is the most annoying part about it all.
Can anyone point me in the right direction? I'm such a numpty when it comes to modrewrite stuff.
Tom
here is your rewrite rule;
RewriteRule ^town/([^/]*)-([0-9]+)\.html$ town.html?tID=$2&tN=$1 [L]
this rewrite rule rewrites URLs ONLY if they are something similar to: town/manchester-64.html
If it's not working , then your URL is NOT like that.
精彩评论