htaccess not working properly for sub url having more slashes
I am having 2 websites. Call it 5p_front (http://localhost/5p_front/) (Developed in OctoberCMS) and 5p_group (http://localhost/5p_group/) (Developed in CakePHP)
In 5p_front i have an .htaccess file and in which i put a condition which will redirect to 5p_group website as soon as it finds a word having 5p_group_login in url. Here is code below
.htaccess
RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301]
So if someone tries to go here for example http://localhost/5p_front/5p_group_login , they will simply be redirected to here http://localhost/5p_group/ .
This works fine from home page and other subpages like about page for example http://localhost/5p_front/we-are-5p-group .
However i have one product inner page http://localhost/5p_front/product/10 and if i hover the menu item which allows me to redirect to login page, it is showing this url http://localhost/5p_front/product/5p_group_login and hence when i click on it, i am unable to redirect at http://localhost/5p_group/ as it is only recirecting to this current url only http://localhost/5p_front/product/5p_group_login which should not be the case.
Additionally, My Menu is coming dynamically and i have used Static Pages plugin to create menus which OctoberCMS provides and i have created "Login" menu link like below.
How can i redirect the url at http://localhost/5p_group/ even if the user is at http://localhost/5p_front/product/10 and clicks on "Login" link which is showing http://localhost/5p_front/product/5p_group_login if i mouse hover on it.
Can someone guide me here what should i do in this scenario.
Thanks
Answer
Your rule
RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301]
when placed in 5p_front/.htaccess
will affect only URIs that begin with /5p_front/5p_group_login
(because of the leading ^
in your pattern) so /5p_front/product/5p_group_login
will not match.
If you want to rewrite URLs that have 5p_group_login
anyhwere, just use:
RewriteRule 5p_group_login http://localhost/5p_group [L,R=301]
Related Questions
- → .htaccess - not routing to public folder
- → Laravel 4.2 application occurs unnecessary redirection after uploading live server
- → Htaccess negation
- → Building sitemap for 2 wordpress install under 1 domain
- → htaccess not working properly for sub url having more slashes
- → How to give access execute specific php file in server?
- → 301 Redirection from no-www to www in wordpress
- → Cyclical redirection at the start laravel 5 project
- → Can't route in Laravel framework
- → codeigniter seo url with htaccess
- → PHP Seo Friendly URL
- → Convert URL to SEO Friendly
- → IP Canonicalization (WordPress)