Jump to content

Rewrite Rule Help


kampbell411

Recommended Posts

Are you saying that on your server you have a directory in your root called city that has an FL folder with a Miami.html file inside of it and that you wish the url to appear as just /FL/Miami.html without the word city?

 

RewriteEngine On
RewriteRule ^(FL/Miami\.html)$ /city/$1 [L]

 

I assume you have more than just the one URL you wish to rewrite, but since you didn't specify any parameters, I'm not going to bother hypothesising as I could be completely off. Either way it's just a matter of creating the correct regular expression to match the first half.

Link to comment
https://forums.phpfreaks.com/topic/250169-rewrite-rule-help/#findComment-1284396
Share on other sites

Your right sorry. Here is basically all the details. I am trying to write while passing two variables, a state abbreviation and a city name.

 

http://www.example.com/city/{stateAbreviation}{cityName}.html

 

to

 

http://www.example.com/{stateAbreviation}{cityName}.html

 

I am linking to http://www.example.com/city/{stateAbreviation}{cityName}.html from http://www.example.com/state/{stateAbreviation}.html

 

as http://www.example.com/{stateAbreviation}{cityName}.html but I am getting a 404.

 

Here is what I tried in my root htaccess of my domain but it didn't work. Should I try putting an htaccess in my city directory?

 

RewriteRule ^([A-Z]{2})/(.*)\.html /city/index.php?st=$1&id=$2 [L]

 

also tried

 

RewriteRule ^(.*)/(.*)\.html /city/index.php?st=$1&id=$2 [L]

Link to comment
https://forums.phpfreaks.com/topic/250169-rewrite-rule-help/#findComment-1284470
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.