I have this htaccess file in my root dir to rewrite www to non-www
RewriteEngine On
Options -MultiViews
Options +FollowSymLinks
Options All -Indexes
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
Then in my directory for blogs I have these to help clean up the URL
RewriteRule ^/?author(?:/(?:.*/)?([^/]+))?/?$ index.php?author=$1 [L,NC,QSA]
RewriteRule ^/?tag(?:/(?:.*/)?([^/]+))?/?$ index.php?tag=$1 [L,NC,QSA]
RewriteRule ^/?post(?:/(?:.*/)?([^/]+))?/?$ index.php?post=$1 [L,NC,QSA]
RewriteRule ^/?page(?:/(?:.*/)?([^/]+))?/?$ index.php?page=$1 [L,NC,QSA]
All other directories and stuff redirect to non-www correctly EXCEPT my blogs dir. I'm assuming something I did with the blog redirects is messing up the main one. How can I make my blogs directory also redir to non-www correctly?
Related
I'm trying to setup my .htaccess file to redirect from oldsite.com to newsite.com, with just one exception: If the user visits http://oldsite.com/cal then I want it to display the cal.html file in the root directory.
Here's the current .htaccess file that I've got (which doesn't work):
Options +FollowSymlinks -MultiViews
RewriteEngine On
# this page can be served .. (not working)
RewriteRule /cal http://oldsite.com/cal.htm [L,NC]
# .. but rewrite everything else (this works fine)
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com [NC]
RewriteRule ^(.*) http://newsite.com/$1 [R=301,L,NC]
What do I mean by it doesn't work? Well, it just redirects http://oldsite.com/cal to http://newsite.com/cal instead of displaying http://oldsite.com/cal.html
Change it to this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^cal/? cal.htm [L,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com [NC]
RewriteRule ^ http://newsite.com%{REQUEST_URI} [NE,R=301,L]
Notes
if oldsite and newsite live on different servers, you don't even need the RewriteCond.
you could also invert the order of the rules, in which case the main rule would be RewriteRule ^(?!cal/?$) http://newsite.com%{REQUEST_URI} [NE,R=301,L]
I have created a .htaccess file to rewrite url. But when i opened the url which should be rewrited by the htaccess the url was not changed. Here is my .htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule seller/username/(.*)/ seller.php?username=$1
RewriteRule seller/username/(.*) seller.php?username=$1
Please help me out as i am beginner to htaccess. Thanks in advance
Have it this way:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+seller/\.php\?username=([^\s&]+) [NC]
RewriteRule ^ /seller/username/%1? [R=302,L]
RewriteRule ^seller/username/(.+)/?$ seller.php?username=$1 [L,QSA]
I need to redirect url from
website.com/search.php?city=india&keyword=laptop
to
website.com/search/india/laptop
How can i do this with htaccess
Present code in my htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ search.php?city=$1&keyword=$2
You can use this rule in your root .htaccess file:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+search\.php\?city=([^&]+)&keyword=([^\s&]+) [NC]
RewriteRule ^ /search/%1/%2? [R=301,L,NE]
RewriteRule ^search/([\w-]+)/([\w-]+)/?$ /search.php?city=$1&keyword=$2 [L,QSA]
This is what I need to do:
website EXAMPLE with url
/?VVWM=$59095-K9T-50U00-VX0U**|jDDQvcZbTESbGqI2AJ8Iww|dIWecCGiGUive6I2AJ8Iww||||1|0$&utm_source=followup-offerte&utm_medium=email&utm_campaign=VVWM
has to redirect to:
http://www.sluitsnel.nl/goedkope-scooterverzekering/?VVWM=$59095-K9T-50U00-VX0U**|jDDQvcZbTESbGqI2AJ8Iww|dIWecCGiGUive6I2AJ8Iww||||1|0$&utm_source=followup-offerte&utm_medium=email&utm_campaign=VVWM
So the indication for this redirection is:
http://www.goedkope-scooterverzekeringen.nl/?VVWM=$59095-K9T-50U00-VX0U
Thanks in advcance!
Greetings,
Ivar
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?goedkope-scooterverzekeringen\.nl$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+\?(VVWM=$59095-K9T-50U00-VX0U[^\s]*) [NC]
RewriteRule ^ http://www.sluitsnel.nl/goedkope-scooterverzekering/?%1 [R=301,L,NE]
I need modificate file request http://subdomain.site.com/file.txt -> http://site.com/file-subdomain.txt
Please help with htaccess code. Thanks!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(subdomain)\.(site\.com)$ [NC]
RewriteRule ^file\.txt$ http://%2/file-%1.txt [L,R=301,NC]
EDIT:
RewriteCond %{HTTP_HOST} ^(subdomain)\.(site\.com)$ [NC]
RewriteRule ^file\.txt$ /file-%1.txt [L,NC]