Jump to content

Regex in .htaccess


wpt394

Recommended Posts

So I know this may not be in php exactly, but I think it's pretty close....

 

I have a website on which I've been using the Rewrite Rule in my .htaccess file to make dynamic urls appear static.

 

For example, at first I would take a url that looked like:

 

http://www.example.com?variable=two%20words  (call this Version 1)

 

and transform it to this:

 

http://www.example.com/two%20words  (call this Version 2)

 

 

But....now I've switched the spaces (%20) to dashes (-) so the urls look like

 

http://www.example.com/two-words (Version 3)

 

 

The question is, how do I use a 301 redirect to make the version 2 urls redirect to the version 3 urls?  Thanks for any help.

 

Link to comment
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.