I'm trying to redirect people who go to my site but I want it to not show in the URL.
http://www.example.com/ -> http://www.example.com/dev/
except the /dev part shows in the URL when the redirection takes place, how do I hide it so it stays as http://www.example.com/? Here's my HTAccess file..
RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ dev/index.php [L]
</IfModule>
Any help would be appreciated, thanks.
Related
I have strange problem with .htaccess file.
The file is placed inside directory www.mydomain.com/t/ and looks like that:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/\.]+).html$ ../index.php [R=301]
I would like to redirect all .html files to my main page www.mydomain.com
Redirection works but I am redirected to www.mydomain.com/server/file/path/t/index.php not to www.mydomain.com (or www.mydomain.com/index.php)
Where did I make a mistake?
Thank you in advance for help.
Add this rule
RewriteRule ^(.*)$ /index.php?$1 [L]
Is possibile convert this url:
http://corpovigiligiuratife.it/promo.php
to
http://corpovigiligiuratife.it/promozione-porta-un-amico
with htaccess MOD Rewrite?
I did several searches but I could not figure out how to convert this url.
I have 2 static 2 url and not a dynamic url.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^promozione-porta-un-amico$ promo.php [L]
</IfModule>
Use this as the content of the .htaccess file:
RewriteEngine On
RewriteRule ^promo.php$ promozione-porta-un-amico [R=301]
It will redirect the user from promo.php to promozione-porta-un-amico
The R=301 means that this link is Moved Permanently.
I want to use htaccess to redirect certain pages to its equivalent in another domain, other pages redirect to homepage.
Like that:
http://old-domain.com/certain-page redirected to: http://new-domain.com/certain-page
http://old-domain.com/another-certain-page redirected to: http://new-domain.com/another-certain-page
Only these pages will be redirected, otherwise, pages have to be redirected to the new domain home page.
http://old-domain.com/non-certain-page redirected to: http://new-domain.com
This is my try:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^certain-page$ http://new-domain.com/certain-page [R=301,L]
RewriteRule ^another-certain-page$ http://new-domain.com/another-certain-page [R=301,L]
</IfModule>
But don't know how to exclude other pages.
Any help here?
Thanks in advance!
I'm not sure what you mean by
But don't know how to exclude other pages
But you are already excluding the pages when you create specific rules for them. This should work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#redirect specific pages
RewriteRule ^certain-page$ http://new-domain.com/certain-page [R=301,L]
RewriteRule ^another-certain-page$ http://new-domain.com/another-certain-page [R=301,L]
#Redirect everything else to homepage
RewriteRule ^(.*)$ http://new-domain.com/ [R=301,L]
</IfModule>
Let me know how this works for you. If you need to clear you cache before trying these new rules.
Another answer was mentioned here, thank to anubhava
With redirect without need to use Rewrite :
RedirectMatch 301 ^/.+ http://www.newdomain.com/
So, the answer can be also:
#Redirect specific pages
redirect 301 /certain-page http://new-domain.com/certain-page
redirect 301 /another-certain-page http://new-domain.com/another-certain-page
#Redirect everything else to homepage
RedirectMatch 301 ^/.+ http://new-domain.com
I have two websites:
http://example.com
http://example.com/sub
I have a page, let's say:
http://example.com/sub/page1
Is there any way (using .htacces) to make it possible to access page1 via this url:
http://example.com/page1?
Redirect 301 won't do the work, because I don't need redirects. Is there any way to omit '/sub/' for certain urls, like http://example.com/sub/page1 ?
Yep, there is. Do the following within your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# This would rewrite any URL that starts with /sub to /
RewriteCond %{REQUEST_URI} /sub
RewriteRule ^sub/(.*)$ /$1 [L]
<IfModule>
Edited to meet the OP's requirements.
I want to redirect all user page requests to a page on the same domain.
For example, I have an "under construction, BRB" page that I want all users to see when they try to access ANY page on the site.
I tried using this:
Redirect 302 / http://www.domain.com/index2.php
What that does is try to apply the redirect to the index2.php page as well and it gets stuck in a loop where the user then sees this until the browser stops.
http://www.domain.com/index2.phpindex2.phpindex2.phpindex2.php etc., etc,
Any idea on how to write that rule to except that page?
You have to exclude the file you want to redirect to. Here’s an example with mod_rewrite:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule !^index2\.php$ /index2.php [L,R=302]
</IfModule>
To prevent endless looping (index2.php <--> index2.php):
Only redirect If URL to be redirected does NOT contain the string 'index2.php'
RewriteCond %{QUERY_STRING} !index2.php
RewriteRule ^(.*)$ /index2.php [L,R=301]
You could use mod_rewrite
<IfModule mod_rewrite.c>
RewriteCond {REQUEST_URI} !=/index2.php
RewriteEngine on
RewriteRule ^.*$ /index2.php
# End .HTACCESS
</IfModule>
I'd be more inclined to use the slightly different
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/.*$ /index2.php [R=307,L]
</IfModule>
This will let you return a moved temporarily status for the redirect.
Omitting this set of flags means that mod_rewrite will return a 302 Found status by default.
HTH
cheers,