I am trying to write some rewrite rules in .htaccess file in order to redirect the old pages of the website to the new php pages. Two of the rules are not working, any idea?
The rules are similar, they are trying to redirect for example from
www.prova.com/YC/13123.html to www.prova.com/YC/YC.php?capitolo=13123
the rules are working except for "YC" and "thegamer" (there is a comment in the code added to explain which one).
RewriteRule ^.*YC/(.*)\.(html)$ YC/YC.php?capitolo=$1 [R=301] <-- not working
RewriteRule ^.*RS/(.*)\.(html)$ RS/RS.php?capitolo=$1 [R=301]
RewriteRule ^.*BB/(.*)\.(html)$ BB/BB.php?capitolo=$1 [R=301]
RewriteRule ^.*thegamer/(.*)\.(html)$ thegamer/Gamer.php?capitolo=$1 [R=301] <-- not working
RewriteRule ^.*CB/(.*)\.(html)$ CB/CB.php?capitolo=$1 [R=301]
RewriteRule ^.*Hellper/(.*)\.(html)$ Hellper/Hellper.php?capitolo=$1 [R=301]
RewriteRule ^.*Dice/(.*)\.(html)$ Dice/Dice.php?capitolo=$1 [R=301]
RewriteRule ^.*Lars/(.*)\.(html)$ Lars/Lars.php?capitolo=$1 [R=301]
Problem Solved, for mistake i uploaded another .htaccess in the 2 folder that were not working :)
Related
Soo i have this htaccess file in my subfolder for a project:
RewriteEngine On
# HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R]
RewriteRule ^homepage$ index.php [L]
RewriteRule ^news$ news.php [L]
RewriteRule ^store$ store.php [L]
RewriteRule ^staff$ teams.php?t=1 [L]
In this file "homepage" works, "news" works and "staff" too but "store" not
I had a similar problem last week but i abandoned it becouse i tried everything:
RewriteRule ^/?news/(.*)$ news.php?art=$1 [L]
Here i want a rewrite rule /news/foobar to /news.php?art=foobar
I know i maybe not understand htaccess fully but if some work why others not?
It can be usefull information i use LiteSpeed Webserver
Soo this is just an answer who has this same problem when you use cyberpanel/openlitespeed you need to restart lsws everytime when you modify your .htaccess only then it will work.
If you use OLS Enterprise you dont need to do this...
I'm trying to create clean urls using .htaccess on my website i have this
RewriteEngine on
RewriteRule ^([^/]*)/$ /full_posts.php?permalink=$1 [L]
RewriteRule ^category/([^/]*)/$ /search.php?category=$1 [L]
the first one is working correctly but the second one is not working, I'm writing both one after another. please help!
The rules you are looking for are:
RewriteRule ^([^/]*)/?$ /full_posts.php?permalink=$1 [L]
RewriteRule ^category/([^/]*)/?$ /search.php?category=$1 [L]
I have made the trailing slash optoinal in both the cases.
You can test your rules on:
http://htaccess.madewithlove.be/
I've read a ton on creating the proper redirects for my project. I found some helpful information, but still having an issue.
Ok, I moving a site from one domain unto another. The directory structure has changed as well.
I want the domain to redirect from a .net domain to a .com domain. Then redirect all of the website sub pages into the correct structure on the new domain. The subpages are working great, but the home page isn't. Here the code that I'm using:
RewriteEngine on
//301 Redirect Old File
RewriteRule oldsite.net newsite.com [R=301,L]
RewriteRule ^p_about.* http://www.newsite.com/about [R=301,L]
RewriteRule ^p_linkresources.* http://www.newsite.com/resources [R=301,L]
RewriteRule ^p_services.* http://www.newsite.com/services [R=301,L]
RewriteRule ^p_events.* http://www.newsite.com/events [R=301,L]
RewriteRule ^p_contact.* http://www.newsite.com/contact [R=301,L]
RewriteRule ^p_testimonials.* http://www.newsite.com/testimonials [R=301,L]
RewriteRule ^p_site_credits.* http://www.newsite.com/resources [R=301,L]
RewriteRule ^p_gallery.* http://www.newsite.com/gallery [R=301,L]
RewriteRule ^p_gallery.* http://www.newsite.com/gallery [R=301,L]
RewriteRule ^p_purchase.* http://www.shop.newsite.com [R=301,L]
I greatly appreciate any help!
This rule:
RewriteRule oldsite.net newsite.com [R=301,L]
Needs to be:
RewriteRule ^$ http://www.newsite.com/ [R=301,L]
Read a ton on creating the proper redirects, but still having an issue.
Moving a site from one domain unto another. The directory structure has changed as well. The subpages are working great, but the home page isn't. Here the code that I'm using:
RewriteEngine on
//301 Redirect Old File
RewriteRule oldsite.net newsite.com [R=301,L]
RewriteRule ^p_gallery.* http://www.newsite.com/gallery [R=301,L]
RewriteRule ^p_purchase.* http://www.shop.newsite.com [R=301,L]
Thanks!
Make sure you have enabled mod_rewrite.
Because your first rule is wrong:
RewriteRule oldsite.net newsite.com [R=301,L]
You can only match REQUEST_URI in the RewriteRule.
It should be like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.net$ [NC]
RewriteRule ^ http://newsite.com%{REQUEST_URI} [R=301,L]
I'm putting online a new version of my site and i have to redirect some old indexed pages to the new ones.
So i have generated an htaccess based on static urls (the old ones redirecting to the new ones).
It work for some of them but it figure out that it make 404 errors on the ones that own get parameters (I think that's the cause).
There is 2 rules, the working one and the one that fails :
<IfModule mod_rewrite.c>
RewriteEngine on
#Working one
RewriteRule old_page_indexed.htm http://newsite.com [R=301,L]
#Not working
RewriteRule PBBios.asp?PBMInit=1 http://newsite.com [R=301,L]
</IfModule>
I've tried to following but not working :
RewriteRule PBBios.asp\?PBMInit=1 http://newsite.com
RewriteRule ^PBBios.asp\?PBMInit=1$ http://newsite.com
Do you have any idea how to do this in htaccess?
Thanks a lot =)
Test against the path and query string independently
RewriteCond %{REQUEST_URI} ^PBBios.asp$
RewriteCond %{QUERY_STRING} ^PBMInit=1$
RewriteRule ^(.*)$ http://newsite.com [R=301,L]