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
https://forums.phpfreaks.com/topic/93442-regex-in-htaccess/
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.