http://local.domain.ro/index.php?/login/login--login--login--produs--horn-metalic
I want to redirect it, permanent, in htacces to the following link:
http://local.domain.ro/produs/horn-metalic
I've searched for this topic, and try some answers but it doesn't help me.
EDIT
This is what I am trying:
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteCond %{QUERY_STRING} ^index.php?/login/login-_-login-_-login-_-produs-_-$ [NC]
RewriteRule ^/produs$ /produs/$1 [NC,L,R=301]
Try this :
RewriteEngine On
RewriteCond %{THE_REQUEST} /index.php\?/login/login-_-login-_-login-_-([^-]+)-_-([^\s]+) [NC]
RewriteRule ^ /%1/%2? [NE,NC,R,L]
Related
So I've been fiddling with .htaccess and I was able to remove both removing a subdirectory and having a non-www subdirection. Please find code below:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*) http://domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(.*)subdir
RewriteRule ^(.*)$ subdir/$1 [L]
This can redirect:
www.domain.com/subdir/file
or
www.domain.com/file
to
domain.com/file
However, it can't redirect
domain.com/subdir/file
to
domain.com/file
That's my only problem with this code. Could somebody enlighten me what am I doing wrong? Any help is much appreciated. :)
You can use an OR condition in conditions:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{THE_REQUEST} /subdir/ [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(?:subdir/)?(.*)$ http://%1/$1 [NC,R=302,L]
I am redirecting traffic between old web and new web and I need to redirect 301 from /hotel.php?hotel=lasvegas&lng=es to http://www.new-web.com/hotel-las-vegas/
How could be possible from htaccess?
I have tried
Rewriterule ^hotel\.php\?hotel=lasvegas\&lng=es http://www.new-web.com/hotel-las-vegas/ [L,R=301]
I think my error is at regular expression. Can anyone help me?
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /hotel\.php\?hotel=lasvegas&lng=es [NC]
RewriteRule ^ hotel-las-begas? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^hotel-las-vegas/?$ hotel.php?hotel=lasvegas&lng=es [L,QSA,NC]
it's very important that you insert best code of redirect 301 in best place of htaccess. for example :
http://www.abartazeha.com/
we replace abartazeha.com instead of abartazeha.ir
...
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
I have been looking all over the internet for this and found many clear documents on how to rewrite a url via htacces. I've gotten so far that htacces is working now, but my specific url(s) won't change. All kind of examples I have tried do not work. Hope someone here can help me with this.
This is my urL :
http://www.stamps-as-a-gift.com/category.php?cat1=Holland&cat2=Water&cat3=Vissen&cat4=Dolfijnen
No I would like it to been seen as:
http://www.stamps-as-a-gift.com/category/Holland/Water/Vissen/Dolfijnen
I like this because it is easier to remember en I have read it's also more SE friendly.
I hope this option is possible for me..thanks!
My code that isnt working:
RewriteEngine on
RewriteRule ^(cat1|cat2|cat3|cat4)/([^/.]+)/([^/.]+)/([^/.]+)$ category.php?cat=$1&cat2=$2&cat3=$3&cat4=$4
Also - do I need to restart apache after every new try ?
You need to use this rule in your root .htaccess:
Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+category\.php\?cat1=([^\s&]+)&cat2=([^\s&]+)&cat3=([^\s&]+)&cat4=([^\s&]+)\s [NC]
RewriteRule ^ category/%1/%2/%3/%4? [R=302,L]
RewriteCond %{THE_REQUEST} \s/+category\.php\?cat1=([^\s&]+)&cat2=([^\s&]+)&cat3=([^\s&]+)\s [NC]
RewriteRule ^ category/%1/%2/%3? [R=302,L]
RewriteCond %{THE_REQUEST} \s/+category\.php\?cat1=([^\s&]+)&cat2=([^\s&]+)\s [NC]
RewriteRule ^ category/%1/%2? [R=302,L]
RewriteCond %{THE_REQUEST} \s/+category\.php\?cat1=([^\s&]+)\s [NC]
RewriteRule ^ category/%1/? [R=302,L]
RewriteRule ^category/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ category.php?cat1=$1&cat2=$2&cat3=$3&cat4=$4 [L,QSA,NC]
RewriteRule ^category/([^/]+)/([^/]+)/([^/]+)/?$ category.php?cat1=$1&cat2=$2&cat3=$3 [L,QSA,NC]
RewriteRule ^category/([^/]+)/([^/]+)/?$ category.php?cat1=$1&cat2=$2 [L,QSA,NC]
RewriteRule ^category/([^/]+)/?$ category.php?cat1=$1 [L,QSA,NC]
Problem: I just did a major update to my companies website and trying to get some redirects to work. Right now if I have
Redirect 301 folder1/oldFile1.html http://www.mysite.com/newFolder1/newFolder2/newFile.html
and when you got to the new set up, I get this instead with a 404
http://www.mysite.com/newFolder1/newFolder2/newFile.htmloldFile.html
any ideas what is causing this?
Note: this only appears to happen to files that are moving from a 1 folder structure to a 2 folder structure.
RewriteOptions inherit
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mysite.com [nc]
rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
Don't mix mod_rewrite rules with mod_alias rules.
Use this instead:
RewriteOptions inherit
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]
RewriteCond %{THE_REQUEST} \s/.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
RewriteRule ^folder1/oldFile1\.html$ /newFolder1/newFolder2/newFile.html? [R=301,L]
I need to make my websites link user friendly. Currently, they look like this:
mydomain.com/post.php?title=News-Feeds-Latest-Addition-Puts-facebook-news-26
I want to make them look like this:
mydomain.com/title/get-back-your-recycle-bin-IT-news-85.html
I've written the following code into my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^title/([^/]*)\.html$ /post.php?title=$1 [L]
I don't know why, but it doesn't work. How can I get it to work?
You can use this code
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/post\.php\?(title)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2.html? [R=302,L]
RewriteRule ^(title)/([^.]+)\.html$ /post.php?$1=$2 [L]
Use this :
RewriteEngine on
RewriteRule ^title/get-back-your-recycle-bin-IT-news-85.html/?$ post.php?title=News-Feeds-Latest-Addition-Puts-facebook-news-26 [NC]
now you can usethis url : mydomain.com/title/get-back-your-recycle-bin-IT-news-85.html