How to remove page extension (i.e. profile.html) with htaccess ? So if I load www.mysite.com/profile.html I need profile.html to be remove it.
this removes only index.html , if I change it to profile.html it just goes to mysite.com and loads home page.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} \/index.html\ HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
Related
I have a basic website with pages and directories. Currently the main landing page is at https://www.example.com/index.php
I would like add a marketing landing page which is located at:
https://www.example.com/app/index.php
I would like for my visitors to land on the marketing page when they come to my site's domain. Naturally I thought of .htaccess redirect, but it doesn't seem to work.
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com[nc]
RewriteRule ^(.*)$ https://www.example.com/$1 [r=301,nc]
// Redirect landing page
Redirect /app/index.php /index.php
Curently I'm getting error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
You can use these rules in your site root .htaccess:
Options +FollowSymLinks
RewriteEngine on
# Rewrite to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
# Redirect landing page
Redirect ^app/index\.php$ /index.php [L,NC]
Also note that .htaccess only supports comments beginning with #
I want to redirect several pages to a PHP page with GET variables. However, when I try to use an .htaccess file, it redirects but changes the URL. I don't want it to change the URL structure when redirecting. How would I do this?
For example, I want to redirect /fly-snooze-cruise to http://example.com/package_listing.php?package-type=fly-snooze-cruise
and /fly-snooze-cruise/orlando-airport to http://example.com/package_listing.php?package-type=fly-snooze-cruise&airport=orlando-airport
Here is my .htaccess code:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^fly-snooze-cruise$ http://www.example.com/package_listing.php?package-type=fly-snooze-cruise [L]
RewriteRule ^fly-snooze-cruise/orlando-airport$ http://www.example.com/package_listing.php?package-type=fly-snooze-cruise&airport=orlando-airport [L]
RewriteRule ^fly-snooze-cruise/orlando-sanford-airport$ http://www.example.com/package_listing.php?package-type=fly-snooze-cruise&airport=orlando-sanford-airport [L]
RewriteRule ^fly-snooze-cruise/melbourne-airport$ http://www.example.com/package_listing.php?package-type=fly-snooze-cruise&airport=melbourne-airport [L]
RewriteRule ^snooze-park-cruise$ http://www.example.com/package_listing.php?package-type=snooze-park-cruise [L]
I've been looking for a precise answer to this question for awhile but couldn't find it.
I've launched a one page website in place of an old website with many pages. Now, I want to redirect everything to www.domain.com. The page uses index.html as the homepage, but I don't want to redirect to that, I just want to redirect to the www.domain.com root.
I tried using:
RewriteRule ^.+$ / [R=302,NC,L]
But that just broke my stylesheet and didn't redirect anything. Other solutions I've seen have redirected to the index.html but I want to redirect to the / root domain.
Also, I want to be sure to redirect all non-www pages to www pages too. Can someone please help me out?
Much appreciated
You have most likely something like this in your httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
If you request a folder (and http://example.com/ is a request to a folder), it will try index.php first, then index.php3, etc, etc, and the first one that exists it will shown. You'll have to delete that from your httpd.conf if you want every request to end up as http://example.com. It'll show a directory view of your www-root folder unless that has been disabled.
Try:
# Any direct request for html/php pages
RewriteCond %{THE_REQUEST} /[^\?\ ]+\.(html?|php.) [NC]
RewriteRule ^ / [L,R=301]
That won't affect images, or style sheets, etc. Note that this matches against the %{THE_REQUEST} variable because internally the %{REQUEST_URI} gets converted to /index.html so you can't match against that.
If you want non-existent requests (which would normally result in a 404) to be redirected as well:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ / [L,R=301]
To force a "www" use:
RewiteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
The crawling properties of site showing
http://www.abc.com/http://www.abc.com/index.php?option=com_toys
http://www.abc.com/http://www.abc.com/index.php?option=com_article
http://www.abc.com/http://www.abc.com/index.php?option=com_play&view=category&vid=10
The site been crawled like this, with errors coming in as duplicate url. Correct url is
http://www.abc.com/index.php?option=com_toys
http://www.abc.com/index.php?option=com_article
http://www.abc.com/index.php?option=com_play&view=category&vid=10
is there any way to 301 redirect
i tried using
RewriteCond %{REQUEST_URI} ^.*/http://www.abc.com.*$
RewriteRule .* index.php [R=301,L]
But its not achieving the desired as redirecting to http://www.abc.com/index.php
How to redirect through htaccess from incorrect url to correct url sttructure off site
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 %{THE_REQUEST} ^[A-Z]{3,}\s/+http://.+?(/index\.php\?[^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]
Try this code :
RewriteEngine On
RewriteRule ^http://www.abc.com/index.php /index.php [QSA, R=301]
In my htaccess file I have the following redirections:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteRule index.html$ Controller/index.php [L]
</IfModule>
I want index.html (which does not exist) to be redirected to my controller.
index.php (which exists) should be my home page.
Now, my homepage is not working when typing http://www.domain.com/ in my browser. That URL redirects to my controller.
http://www.domain.com/index.php works fine, bringing my homepage.
How do I set index.php as my index file keeping my redirection for the controller?
If I've understood your situation correctly, you just want to specify DirectoryIndex in your .htaccess file so that it only points to index.php:
DirectoryIndex index.php
Between that and your rules, that leads to the following URL to file mappings:
http://www.example.com/ -> /index.php
http://www.example.com/index.php -> /index.php
http://www.example.com/index.html -> /Controller/index.php