after a long search I finally created an htaccess file with the rules i need. In the local host everything works fine but on the GoDaddy hosting only the half rules are working... does anyone had the same problem or know how to solve it? Thank you
# THIS IS NOT WORKING / Returns a page not found error
RewriteEngine On
RewriteRule ^/?customize/?$ all_poi.php
RewriteRule ^/?santorini/?$ santorini.php
RewriteRule ^/?aboutus/?$ aboutus.php
RewriteRule ^/??tours/?$ all_tours.php
RewriteRule ^/?tours/([0-9]+) tours.php?tour_id=$1& [L]
# Redirects to https / WORKING
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]
#remove trailing slash / WORKING
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301] # <- for test, for prod use [L,R=301]
# Removes index.php from ExpressionEngine URLs / WORKING
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
Related
I know that there are too many questions and answers about this so i have to apologize in advanced but nothing works for me.
I lunched my website in Godaddy/Linux Hosting and trying to apply a rewrite for my urls. What it looks like now is
https://www.mywebsite.com/tours/tour_id=15
and i would like it ot be
https://www.mywebsite.com/tour/15 or even better insted of the ID to GET the title from the sql (which if is not possible through htaccess i can do it with php) My Own Title https://www.mywebsite.com/tour/My Own Title
I am really new in htaccess, below is what is already written in the file
# Redirects to https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Remove trailing slash in the end
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
I would be grateful for any help
Add to top of .htaccess this rewrite rule:
RewriteEngine On
RewriteRule ^tour\/\d+$ /tours/tour_id=$1 [L]
So my issue is if I visit my website it is unsecured. However, if I put https://www.websitename.co.uk it will display the website with https and secure bar. However, when I upload my htaccess file the website just doesn't want to connect.
If I comment out the code below from the htaccess file, the website works but doesn't show secure. If I add that code it just gives me the error message as seen in the image.
# Redirect http to https editor nathan 18/01/2017
#RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
htaccess File
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
# Redirect http to https editor nathan 18/01/2017
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect non www. to www.
RewriteCond %{HTTP_HOST} !^www\.MYWEBSITE\.co\.uk
RewriteRule (.*) http://www.MYWEBSITE.co.uk/$1 [R=301,L]
# Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1? [R=301,L]
# Remove .php ONLY if requested directly
RewriteCond %{THE_REQUEST} (\.php)
RewriteRule ^(.+)\.php /$1 [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
Please change this line:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Into this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This means if the visitor go to http (which is port 80) will get redirect to https (which is 443)
My .htaccess was working perfectly till yesterday. Surprisingly, I made no changes to the website.
The .htaccess lines redirects webite.com to https://www.website.com.
Right now, it redirects website.com to https://website.com
I tried modifying it but it did not change.
Find my .htaccess below:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php?$ http://www.website.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^website\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.website\.com$
RewriteRule ^(.*)$ https://www.website.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
If you are on a shared hosting environment; another user may have introduced another .htaccess file which is over-riding your .htaccess file. How .htaccess files can override each other can be found here
http://httpd.apache.org/docs/2.2/howto/htaccess.html
Replace your current code to force HTTPs and WWW with this:
RewriteEngine On
#Force SSL and WWW
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NE]
This will force WWW and SSL on everything.
I would like redirect http://example.com/index.php?a=music to http://example.com/music (where the number is a variable/dynamic). My site is http : / / example . com
I added the following line to my mod-rewrite rules in my .htaccess file:
RewriteRule ^index\.php$/?/a/=(.*)$ http://example.com/index.php?a=$1 [L,R=301]
However, it doesn't seem to work. I know I'm doing something wrong, I'm just not sure how to fix it. Any help is appreciated.
Best,
Jeff
Edited:
Thanks Tom,
This is what I have:
Rewritecond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
This should work:
RewriteRule ^(.*)$ /index.php?a=$1 [L]
I am using WAMP and I want to remove index.php from my url and I used this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Then I had to change two lines as I moved my files to sub-directory OOP-Project from:
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
and
RewriteRule ^(.*)$ /index.php/$1 [L]
to:
RewriteRule (.*?)index\.php/*(.*) OOP-Project/$1$2 [R=301,NE,L]
and
RewriteRule ^(.*)$ OOP-Project/index.php/$1 [L]
But, the changes are not taking effect although first time it worked! I tried adding syntax error and it showed the error. Surprisingly, when I moved my files to another folder say OOP-Project-1, it worked. I did a lot of research and found this Changes to RewriteRule in .htaccess not taking effect But it didn't address the problem correctly.
Hope someone helps!