I have an index.php page which has a redirect on to go to home.php
is there anyway using htaccess i can make home.php be hidden so the user just see's the domain name in the address bar?
Yes sure you can use this rewrite rule in your DOCUMENT_ROOT/.htaccess file:
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]
Related
I can open my site like this:
www.mysite.com
or like this:
www.mysite.com/index.php
I want to create a htaccess rule that redirects www.mysite.com/index.php to www.mysite.com. But all my attempts have other side effects. I've tried:
Redirect index.php home.php
RewriteRule ^index.php?$ home.php [NC,L]
RewriteRule ^index.php/?$ redirect_to_home.php [NC,L]
But all of these mess up the original index.php call. So it does redirect but then the normal mysite.com link doesnt work anymore.
Any ideas?
Could you please try following.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} index\.php
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$
RewriteRule ^ %1 [R=301,L]
Explanation:
Making RewriteEngine On to make the rules work.
Mentioning condition by RewriteCond to REQUEST_FILENAME which checks if mentioned file in browser is present.
Then checking if THE_REQUEST which has complete details of request(including URL and GET/POST method) if it has index.php in it.
Now checking if REQUEST_URI is having index\.php in requested url, where saving everything before it to temp buffer memory to retrive its value later(basically its domain name).
Finally in RewriteRule to redirect complete URL with index.php to till domain name only as per requirement(R=301 is for permanent redirection on browser side).
Use this redirect rule to remove /index.php from any path:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
How can I redirect the following in my Apaches .htaccess file from
http://example1.com/folder/index.php to http://example2.com/index.php?
You can use:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?siteone\.com$ [NC]
RewriteRule ^folder(/.*)?$ http://www.sitetwo.com$1 [L,R=301]
How to redirect my site from domain.pl/category/post and domain.pl/category/subcategory/post to domain.pl/post?
For example:
Now is:
http://yonelle.pl/zabiegi/oferta/zabiegi-na-twarz/urzadzenia-i-technologie/mezo-odmladzanie-mezorollerem-dmn-mikronakluwanie/
I want redirect to
http://yonelle.pl/zabiegi/mezo-odmladzanie-mezorollerem-dmn-mikronakluwanie/
You can try this rule on top of your .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} yonelle\.pl$ [NC]
RewriteRule ^(zabiegi)/.+?/([^/]+)/?$ /$1/$2 [L,R=301,NC,NE]
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 was wondering how in .htaccess I can redirect the following URL:
/mysite.com/blog/Something => /mysite.com/blog.php?tag=Something
Here is a script I've used on a different site however this is a bit simpilar:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?name=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?name=$1
</IfModule>
Thanks in Advance
Just add this rule:
RewriteRule ^blog/(.*)$ blog.php?tag=$1 [L,QSA,NC]
Update: As per your comment this is the rule you will need:
RewriteRule ^blog/([^/]*) blog.php?tag=$1 [L,QSA,NC]
Try adding the following to the .htaccess file in the root directory of your site.
RewriteEngine on
RewriteBase /
#/mysite.com/blog/Something to /mysite.com/blog.php?tag=Something
RewriteRule ^blog/(something)$ blog.php?tag=$1 [L,NC,R=301]
If something is a variable then change the rule to
RewriteRule ^blog/(\w+)$ blog.php?tag=$1 [L,NC,R=301]
If you want the URL to stay the same in the Users browser then drop the R=301 as below
RewriteRule ^blog/(\w+)$ blog.php?tag=$1 [L,NC]