user2287474
user2287474

Reputation: 646

Apache Mod_Rewrite specific URL

I'm just trying to make one specific redirect. After some googling, I try this:

RewriteRule http://domain.com/Quest/ http://domain.com/blank-parent-page/quest/ [R]

and it does't work. Just want to re-write that one URL. I can successfully do it for ALL urls with blank-parent-page in front of them, I just can't get specifics to work. I just want the page from http://domain.com/blank-parent-page/quest/ to show when someone goes to the URL http://domain.com/Quest/ I'm very new to this. I'm sorry for stupid question.

Also, by rewriting this way, will it still work if someone were to use www. before the domain or if there was something like http://domain.com/Quest/?final=stuff

Thanks for taking the tome to read this.

Upvotes: 1

Views: 7425

Answers (2)

anubhava
anubhava

Reputation: 785481

That rule should be rewritten as:

RewriteRule ^Quest/ /blank-parent-page/quest/ [R,L,NC]

Since RewriteRule only matches REQUEST_URI not the full URL with http and domain name.

Upvotes: 0

Jon Lin
Jon Lin

Reputation: 143906

You don't want the http://domain.com/ as part of your regex pattern of a rewrite rule, that'll never be part of the URI.

RewriteEngine On
RewriteRule ^Quest/?$ http://domain.com/blank-parent-page/quest/ [R,L]

That rule needs to be in the htaccess file in your document root.

Also, by rewriting this way, will it still work if someone were to use www. before the domain

yes, it will still work as long as both are pointing to the same document root.

Upvotes: 2

Related Questions