I am a beginner and I coded a hataccess that works as I want on my site but can not redirect to an external site like facebook twitter or linked. Can you help me please. Thank you.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I m studid !
The .htaccess works fine, the problem was my links, the protocol was missing !!!!
Related
my URL is of the type: www.mysite.fr and for any page: www.mysite.fr/index.php/test
I wish that www.mysite.fr/test displays www.mysite.fr/index.php/test (it's more beautiful without index.php!)
I tried this but: www.mysite.fr/test displays the home page instead of the test page
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Try this :
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/(.*)index\.php/(.*)\sHTTP.*$ [NC]
RewriteRule ^ /%1%2 [R=301,L]
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ index.php/$1 [L]
Second line to remove index.php exteranlly.
Fifth line to redirect request to original path internally .
Note: clear browser cache the test
Your method works on my localhost but not on my online site. This is the 5th line that blocks in my opinion but I do not see why even adding a slash before index.
Someone have an idea ?
I've a website built on apache and I've to migrate it into IIS. I don't know nothing about web.config, but I've a very simple .htaccess to translate.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Anyone can help me?
Thanks a lot
Bye
I'm trying to clean my url from this:
https://www.sobarroso.pt/stand-carros-usados/?brand=2&model=&category=&fuel=&kms=&price=
into this:
https://www.sobarroso.pt/stand-carros-usados/alfa-romeo
but when i creat the rule in .htaccess it just doesn´t work.
Here it´s a snippet of my .htaccess
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
And the code i was trying to add was this:
RewriteRule ^stand-carros-usados/alfa-romeo$ /stand-carros-usados/?brand=2&model=&category=&fuel=&kms=&price= [L]
What am i doing wrong? I'm just starting to play with .htaccess so i need you help guys.
Thanks
EDIT:
hey guys, i keep playing with the codes and feel im almost there. this time i used this one
RewriteCond %{REQUEST_URI} ^/stand-carros-usados [NC]
RewriteCond %{QUERY_STRING} ^brand=(.*)&model=(.*)&category=(.*)&fuel=(.*)&kms=(.*)&price=(.*)
RewriteRule (.*) https://www.sobarroso.pt/stand-carros-usados/alfa-romeo? [L]
and it worked. The url is clean but gives me a 404 page. Do you know why?
The old URLs are like this:
http://mywebsite.com/index.php?mode=thread&id=284607
The new URLs would be:
http://mywebsite.com/threads/284607
As you can see, I want to grab the ID # from the old dynamic URLs and point them to the new pretty URLs.
I've tried finding the solution here and elsewhere, but keep having problems removing the "mode=thread" part from the redirect.
Thanks for your help!
Update: Here's some other code that is already in the .htaccess file.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
After a lot of Googling, I found this to work:
RewriteCond %{QUERY_STRING} (^|\?)mode=thread&id=([0-9]+)($|&)
RewriteRule ^index\.php$ http://mywebsite.com/threads/%2/? [R=301,L]
In your .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^mode=thread
RewriteCond %{QUERY_STRING} &id=([0-9]+)
RewriteRule ^index\.php$ /threads/%1? [L,R=301]
i was trying to make my indexhibit installation to use nice urls + domain redirect to make it allways using 'www' in page URL but i've failed. Nice urls works fine but i can't make this www redirect work.
Here is my original htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.+) index.php
I was trying to add those lines
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
before RewriteCond %{REQUEST_FILENAME} -f [OR], after RewriteRule ^(.+) index.php and in any possible place but it allways breaks the page. Can you please advise me how to make it properly ? Thanks in advance :)