Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

So I've used an online .htaccess editor and it's not working for some reason on my test server, here's the content of my .htaccess file.

RewriteEngine On
RewriteRule ^Page/([^/]*)/$ /?Page=$1 [L]

I have also enabled the LoadModule rewrite_module modules/mod_rewrite.so on my WAMP server. Any help is much appreciated.

[Fri Aug 09 12:46:10.130887 2013] [core:alert] [pid 1424:tid 1532] [client 127.0.0.1:50725] C:/wamp/www/Website/.htaccess: RewriteRule: bad flag delimiters

EDIT: tried doing one on my own still having the same issue

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^Page/([a-zA-Z]+)/([0-9]+)/$ index.php?Page=$1
share|improve this question
    
mod_rewrite is doing something - it appears to be enabled and is giving you this error. However, it looks OK to me. Check for unwanted whitespace, especially at EOL, and for any non-visible characters. –  w3d Aug 9 '13 at 16:51
    
When I checked the doesn't seem to be any non-visible characters, maybe if I were to describe what I want the rewrite to do that may clear up the problem. What I want it to is to change where is says something like ?Page=Home to /Page/Home/ –  Callum.K Aug 9 '13 at 17:30
    
Hhmmm, your .htaccess would seem to be doing the complete opposite at the moment? The code you currently have would normally be required for "user friendly/pretty" URLs and internally rewrites /Page/Home/ to /?Page=Home. However, the 'change' in your comment would be an external redirection to the canonical URL. You could have both? –  w3d Aug 9 '13 at 19:31
    
I'm not quite sure what you are saying, I'm trying to change a $_GET variable to something like /Page/Home/. Which part would I need to do to change this, or would I have to change the whole thing? –  Callum.K Aug 9 '13 at 19:46
add comment

1 Answer

up vote 0 down vote accepted

It seems from comments that you are wanting to redirect (I assume) ?Page=Home to /Page/Home/ rather than rewrite the other way round, as you are trying to do in your question?

In which case you would need to do something like:

RewriteCond %{QUERY_STRING} ^Page=(.*)$
RewriteRule .* /Page/%1/? [R=301,L]

NB: The ? at the end of the RewriteRule substitution removes the original querystring.

share|improve this answer
    
I'm not trying to redirect the user I'm trying to change the look of the $_GET variable so it looks like /Page/Home and not ?Page=Home. Thanks anyways. –  Callum.K Aug 10 '13 at 0:07
    
Sorry, I'm not sure that I follow. It looks like you are trying to implement "friendly URLs" ie. /Page/Home rather than ?Page=Home? However, in this case you shouldn't be changing the (look of the) $_GET variable. The $_GET variable would remain the same, but the URL in the address bar is changed to "look friendly". The requested (friendly) URL is internally rewritten (as you are trying to do in the question) back to a querystring to give you your $_GET variable. OR maybe you're doing something completely different? :) –  w3d Aug 10 '13 at 1:36
    
That is indeed what I am trying to get but the code you sent me adds /Page/Home however the $_GET is not changed and still remains there so the url now looks like /Page/Home?Page=Home. –  Callum.K Aug 10 '13 at 4:42
    
Sorry, there should have been a ? at the end of the RewriteRule substitution string to remove the original querystring - I've updated my answer. Is this what you require? To be honest, the code you have in your question is what is required to implement user friendly URLs. This bit here (to redirect from unfriendly to friendly) is only really required if you have an existing "unfriendly" URL structure that you are changing (although it is a good thing to do anyway). –  w3d Aug 11 '13 at 17:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.