Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.