404 page not found in YAMS - .htaccess

I would like some help here. I am using MODx with YAMS module which is for multilingual. I follow the installation and setup document from YAMS but I still get 404 page not found.
I would like to get:
localhost/sub/en/index.php?id=1
localhost/sub/fr/index.php?id=1
localhost/sub/th/index.php?id=1
the original link is
localhost/sub/index.php?id=1
here is rewrite rule in htaccess file. I got the rewrite rule from YAMS in "Server Config" tab.
# Friendly URLs
RewriteEngine On
RewriteBase /sub/
# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]
# Exclude /assets and /manager directories from rewrite rules
RewriteRule ^(manager|assets) - [L]
# Redirect from mydomain.com/rootname to mydomain.com/rootname/
RewriteRule ^en$ en/ [R=301,L]
RewriteRule ^fr$ fr/ [R=301,L]
RewriteRule ^th$ th/ [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^th/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fr/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I am trying to search all the solutions everywhere. still no luck. please suggest or point me what i do wrong?
Thanks in advance

If you are getting links like localhost/en/index.php?id=1 in the frontend You have to fill the "MODx Subdirectory" field with "sub". You will find it in Modules->Yams->Other Params

Actually the problem is .htaccess file. I copys all .htaccess from YAMS and replaces the whole original .htaccess file. To solve my problem, I copy only friendly URL part and replace only this part in original .htaccess file.
here what I copy from YAMS and replace in my .htaccess file:
# Redirect from mydomain.com/rootname to mydomain.com/rootname/
RewriteRule ^en$ en/ [R=301,L]
RewriteRule ^fr$ fr/ [R=301,L]
RewriteRule ^th$ th/ [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^th/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fr/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Many thanks for suggestions.

Related

Use 2 urls for the same directory using htaccess

Is it possible to using htaccess?
I want to keep my original url "menu", but also use /en/menu/ for it.
Here is my code so far (sorry I am terrible at htaccess):
RewriteEngine On
RewriteBase /server/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/menu/ [NC]
RewriteRule ^([^/]+)/([^/]+)en/menu/ [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /menu/ [L,QSA]

Struggling to rewrite the URL using htaccess

I'm totally newbie in htaccess and it has been a month since I'm trying to rewrite this one URL but no luck. Tried searching on the internet a lot and tried out the method that worked for others but not working for me unfortunately.
The htaccess rule for my dynamic page works, for example site/index.php?viewpage=application shows up as site/application
What I'm struggling to do is, I'm trying to rewrite the following url: site/application?name=abcd&date1-2-3&version=5.0 to site/application/abcd/1-2-3/5.0
This is my htaccess code
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?viewpage=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /application?name=$1&date=$2&version=$3 [L]
Try this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !name
RewriteRule ^([^/]+)$ index.php?viewpage=$1 [L]
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ /$1?name=$2&date$3&version=$4 [L]
If you want the last line to be limited with application only , replace with this :
RewriteRule ^application/(.+)/(.+)/(.+)$ /application?name=$1&date$2&version=$3 [L]
UPDATE CODE:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !name
RewriteRule ^([^/]+)$ index.php?viewpage=$1 [L]
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ index.php?viewpage=$1?name=$2&date$3&version=$4 [L,NE]

301 dynamic redirects not correct working

I need to change old dynamic urls to new, so I have created .htaccess file, but something wrong and redirect to ERR_TOO_MANY_REDIRECTS problem.
Below my .htaccess file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^movie/(.+)/$ /cat.php?name=$1 [QSA,L]
RewriteCond %{QUERY_STRING} ^name=(.*)$ [NC]
RewriteRule ^cat\.php$ /movie/%1/? [R=301,L]
You need to check the original URI, and redirect to the pretty URL from that:
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /cat\.php\?name=([^\s&]+) [NC]
RewriteRule ^cat\.php$ /movie/%1/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^movie/(.+)/$ /cat.php?name=$1 [QSA,L]

.htaccess multiple rewrite rules

I currently have a .htaccess rewrite rule that will redirect all urls containing /ws to the /ws/index.php eg. www.domain.com/ws/controller/function
RewriteEngine on
RewriteBase /ws/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
i'm looking to add another redirect, just the same, for all request that contain /email/ so www.domain.com/email/controller/function will redirect to the /email/index.php.
my full .htaccess looks like the code below but it seems the /email/ never gets called.
RewriteEngine on
RewriteBase /ws/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
RewriteEngine on
RewriteBase /email/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
I've tried adding ^/email to the RewriteRule conditional but to no avail.
Any help would be appreciated.
Thanks
You can use:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ws/(.*)$ ws/index.php?url=$1 [NC,L,QSA]
RewriteRule ^email/(.*)$ email/index.php?url=$1 [NC,L,QSA]

Change full url path with .htaccess

I want to change page url with .htaccess my url is 'page.com/web/' and I want to have just page.com. Could you give me htacces code. for example
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /?$1 [L]
Try this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ web/$1 [NC,L]

Resources