I’m using .htaccess (mod rewrite) to have pretty looking SEO friendly URLs. I have a form where user could change his / her account’s password. I provide information with Jquery to the user that his / her password has changed and in 3 seconds page will be redirected to login page.
setTimeout(function() {window.location.replace("http://localhost/projects/v4/login/#login");} , 3000);
For some reason this code redirects to http://localhost/projects/v4/#login instead of http://localhost/projects/v4/login/#login. I mentioned about SEO friendly URLs in the begining of my question. I started to think this problem occurs because I am using base URL between <head></head> element.
<base href="http://localhost/projects/v4/" />
Is there any solution for this problem or am I mistaken and this problem occurs because of some totally different problem?
.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /projects/v4/
RewriteRule ^index/ index.php [L]
# MEMBERS
ReWriteRule ^login/(.*) ?module=login&a=$1 [L]
# MODULES
RewriteRule ^([^/\.]+)$ ?module=$1 [L]
# LAST ONES
#RewriteCond %{THE_REQUEST} \?(ref=.*)?\ HTTP [NC]
#RewriteRule .? http://localhost/projects/v4%{REQUEST_URI}? [R=301,L]
</IfModule>
Thank you for your time and concern.
You issue is not caused by JavaScript, but by your
.htaccessfile. Make sure that your rules are correct, and not conflicting.The
[R=301,L]rule should be last, because it matches every URL atv4, including login. Also, swapMODULESandMEMBERS, because the module rule also matches the member rule.