Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess 301 redirect: Dynamic to Static page 1

Status
Not open for further replies.

monkey64

Technical User
Apr 27, 2008
69
GB
I'm having dificulty redirecting a dynamic page to a static one using the following in my .htaccess file.
I just get "The requested URL /accessory_header_menu.asp was not found on this server."

Code:
RewriteCond %{HTTP_HOST} ^[URL unfurl="true"]www.mydomain.co.uk[/URL]
RewriteCond %{QUERY_STRING} ^accessory_header_menu.asp?category=monkeys$ [NC]
RewriteRule ^(.*)$ [URL unfurl="true"]http://www.mydomain.co.uk/index.php[/URL] [R=301,L]

Can anyone help?
 
I don't think I made my earlier post that clear.

My objective was to set up a simple 301 redirect.
The problem I faced was that my links all had parameters such as: index.php&mylink=4. Doing a simple redirect just didn't work.

Anyway, I found an example which worked for me (as well as 50 which did not!).

Code:
RewriteCond %{QUERY_STRING} category=mycategory
RewriteRule accessory_header_menu\.asp [URL unfurl="true"]http://www.mysite.co.uk/mypage.htm?[/URL] [R=301,L]

Some of my redirect query strings had plus signs.
Allowing the .htaccess file to parse these, resulted in an error.

To get round it, I used this ([^.%]) in place of the plus sign. The dot matches any character.

Hope it helps someone someday...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top