Mobile app version of vmapp.org
Login or Join
Kimberly868

: RewriteRule not working properly in my Ubuntu server 14.04 running in Windows Azure In my server I kept signup.php and in .htaccess I kept this thing - RewriteRule ^/registration/?$ http://www.example.com/signup

@Kimberly868

Posted in: #Apache #Azure #Htaccess #Server #Ubuntu

In my server I kept signup.php and in .htaccess I kept this thing -


RewriteRule ^/registration/?$ www.example.com/signup [R]


But this is not redirecting example.com/registration/ to example.com/signup/
However I tried with other things like -


RewriteRule ^/registration/?$ signup.php [R]


and also -


RewriteCond %{REQUEST_URI} ^registration/$ [NC] RewriteRule ^(.*)
example.com/signup [R=301,L


But nothing is working out. It's showing me 404 error message. I am using Ubuntu 14.04 in Windows Azure server running Apache 2.2.22

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kimberly868

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

I see some problems with your rewrite rules.


You don't explicitly turn on mod_rewrite with RewriteEngine On
When using rewrite rules in your .htaccess file the slash at the beginning of them is assumed. Having a slash at the beginning of the rule will prevent rewrite from executing the rule. (This is different than if the rule were in httpd.conf where the slash at the beginning is required.)
You have an extraneous in your first rule. Having should be a back reference to whatever is in parenthesis in the first part of the rule. There are no parenthesis, so that rule is not going to work right.
When redirecting with mod_rewrite, I recommend always using the L flag to ensure that it is the last rewrite rule triggered.
You almost always want to specify the "permanent" type of redirect with R=301 so that it doesn't do temporary redirect which are less SEO friendly.
Your last rule should be on multiple lines.
Your last rule is missing a closing ].


I would recommend first trying to use a simple redirect directive for something this simple:

redirect permanent /registration /signup


If that doesn't work you can fix your rewrite rule:

RewriteEngine On
RewriteRule ^registration/?$ /signup [L,R=301]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme