.htaccess : wrong redirection - .htaccess

This is my htaccess :
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# MON COMPTE
RewriteRule ^mon-compte/connexion/?$ mon-compte-login.php [L,QSA]
RewriteRule ^mon-compte/mes-informations/?$ mon-compte.php [L,QSA]
RewriteRule ^mon-compte/mes-points-de-fidelite/?$ mon-compte-pts.php [L,QSA]
RewriteRule ^mon-compte/mes-commandes/?$ mon-compte-commandes.php [L,QSA]
RewriteRule ^mon-compte/mes-identifiants/?$ mon-compte-modif-identifiants.php [L,QSA]
RewriteRule ^mon-compte/deconnexion/?$ mon-compte-deconnexion.php [L,QSA]
BUT...
When i click on a link with, for example, href="[...]/mon-compte/mes-commandes", my browser open "mon-compte/mes-commandes" but display mon-compte.php... and it is the same problem with all my "mon-compte" links... Every links display "mon-compte.php".
Thanks for helping... :(

Related

how to hide id = from url using htaccess file

I need the url
from
localhost/project/category?c=electronics
to
localhost/project/category/electronics
I have tried
RewriteRule ^category/([^/\.]+)?$ /category.php?c=$1 [L]
RewriteRule ^category/+?$ /category.php?c=$1 [NC,L]
With your shown samples and attempts please try following htaccess rules. Please do clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /
##External redirect to url change in browser.
RewriteCond %{THE_REQUEST} \s/(project/category)\.php\?c=(\S+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal rewrite to category.php in backend.
RewriteCond %{DOCUMENT_ROOT}/$1/$2.php -f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ %{DOCUMENT_ROOT}/$1/$2.php?c=$3 [QSA,L]
RewriteEngine on
RewriteBase /
RewriteRule ^project/category/([0-9a-z]+)$ /project/category?c=$1 [L]
Why is "project/" missing in your original try ?
You have to specify the full path.
You can try this simple rewriteRule wich should works.

Redirected URL through .htaccess is being redirected to the different location

My .htaccess has the following code :
RewriteRule ^([A-Z]+)$ listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
With this rule I am trying to achieve 301 redirect from spb.com/test_1/XY to spb.com/test_1/listings/XY
However, it is redirecting to spb.com/path/to/test_1/in_server/test_1/listings/CT
and I tried changing .htaccess to as follows:
RewriteRule ^([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
RewriteRule ^/([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
RewriteRule ^/([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^/listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
Nothing seems to work.
Please guide me in this regard. Thank you community :)
Could you please try following, based on your shown samples only. Please make sure you clear your browser cache before testing your URLs
RewriteEngine ON
RewriteRule ^([A-Z]+)/?$ /test_1/listings/$1 [R=301]
RewriteRule ^test_1/listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]

Htaccess if url starts with

So I am no hero when it comes to htaccess. So forgive me if I have the complete wrong code below.
Here are the example links (behind each link a number to which I shall refrer bellow to which htaccess part they should be linking to):
website.com/home/ #1
website.com/home/page2/ #1
website.com/projects/ #1 or #2 (doesnt matter since the first GET will be page in both cases)
website.com/projects/staticpage/ #1
website.com/projects/filter1/ #2
website.com/projects/filter1/filter2/ #2
The current code I am using is (part 1):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/projects/$
RewriteRule ^([-A-Za-z0-9-_]+)/?$ index.php?page=$1 [L,QSA]
RewriteRule ^/?([-A-Za-z0-9-_]+)/([-A-Za-z0-9-_]+)/?$ index.php?page=$1&sub=$2 [L,QSA]
RewriteRule ^/?([-A-Za-z0-9-_]+)/([-A-Za-z0-9-_]+)/([-A-Za-z0-9-_]+)/?$ index.php?page=$1&sub=$2&sub-sub=$3 [L,QSA]
The other bit of the htaccess (part 2):
RewriteEngine On
RewriteBase /
RewriteRule ^([-A-Za-z0-9-_+]+)/?$ index.php?secondpart=$1 [L,QSA]
RewriteRule ^/?([-A-Za-z0-9-_+]+)/([-A-Za-z0-9-_+]+)/?$ index.php?secondpart=$1&filter[]=$2 [L,QSA]
RewriteRule ^/?([-A-Za-z0-9-_+]+)/([-A-Za-z0-9-_+]+)/([-A-Za-z0-9-_+]+)/?$ index.php?secondpart=$1&filter[]=$2&filter[]=$3 [L,QSA]
The filters are dynamic so it is not possible to get them to exclude.
I get it to skip the first part when the url is equal to: website.com/projects/ but,
when I change the url to: website.com/projects/filter1/ I can't get it to grab the second part.
If you could help me fix this thank you very much.
You can do something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/pagesearch/(staticpage1|staticpage2)/
RewriteRule ^ - [L]
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?page=$1&sub=$2 [L,QSA]

htaccess - Redirect to joomla webpage

I know this is probably a very simple question but I do not manage it to get it working.
I have a joomla application with the following url: http://www.nmo-online.com/news/final and I would like to point it to http://www.nmo-online.com/client/frontend/app/final but with keeping the first url.
So I put a .htaccess file on my server situated in the root folder with the following content:
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .*nmo-online.com$
RewriteRule ^news/final client/frontend/app/final [L]
The redirection seems to work but I always get redirected to the homepage, which is http://www.nmo-online.com/weather.
Any help is very appreciated.
enne
Edit: Here is the complete htaccess-file
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .*nmo-online.com$
RewriteRule ^$ client/frontend/questionnaire/index.php [L]
RewriteRule ^weather client/frontend/app/weather [L]
RewriteRule ^news/final client/frontend/app/final [L]
RewriteRule ^flight/search-flight client/frontend/app/search-flight [L]
#Joomla backend
RewriteRule ^administrator client/frontend/app/administrator/ [L]
#Questionnaire backend
RewriteRule ^backend client/backend/index.php [L]

Url rewrite and trim url

I need your precious help.
I have an url:
http://domain.com/v/12345
My ht access is set to pass 12345 to php script like:
htaccess:
RewriteRule ^v/([a-zA-Z0-9_-]+)$ /script.php?v=$1 [L]
script php:
http://domain.com/script.php?code=12345
and works perfectly but.. and there is a but, I would write my url so:
http://domain.com/12345/my-dog-is-very-fat
can you help to change my htaccess to works so? Because if I use /my-dog-is-fat or just / I get an 404 error.
I try to explain better:
I would share link with seo keywords in the url, example
mydomain.com/alphanumericCode/thi-is-my-dog-article
where alphanumericCode is get of myscript.php?V=
This is my htaccess:
RewriteEngine On
RewriteRule ^view/([a-zA-Z0-9_-]+)$ /view.php?v=$1
RewriteRule ^folder/([a-zA-Z0-9_-]+)$ /filefolderlist.php?f=$1
RewriteRule ^home$ /index.php [L]
RewriteRule ^report$ /report.php [L]
RewriteRule ^play/([a-zA-Z0-9_-]+)$ /play.php?v=$1 [L]
###Added by anubhava
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]
##end
RewriteRule ^privacy-policy$ /privacy.php [L]
ErrorDocument 404 404.php
You can have a new rule for the new URI scheme:
RewriteEngine On
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]

Resources