.htaccess - arabic slugs - .htaccess

The slug with me is not supporting Arabic and when I try to write in Arabic it deletes it and replaces it with -cat
so I want it to be supporting Arabic and I want to remove -cat from the whole file not just the category.
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
#Category
RewriteRule ^([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)-([0-9_-]+)-([0-9_-]+)-([0-9_-]+)$ cat1.php?id1=$2&id2=$3&id3=$4&id4=$5 [QSA]
RewriteRule ^([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)-([0-9_-]+)-([0-9_-]+)$ cat1.php?id1=$2&id2=$3&id3=$4 [QSA]
RewriteRule ^([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)-([0-9_-]+)$ cat1.php?id1=$2&id2=$3 [QSA]
RewriteRule ^([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)$ cat1.php?id1=$2 [QSA]
RewriteRule ^([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)$ cat1.php?id1=$2
RewriteRule ^([a-zA-Z0-9_-]+)--([a-zA-Z0-9_-]+)-cat([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+) cat1.php?id1=$3&id2=$4
RewriteRule ^cat([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)$ cat1.php?id1=$1&id2=$2
RewriteRule ^cat([a-zA-Z0-9_-]+)$ cat1.php?id1=$1&v=3
RewriteRule ^itm([a-zA-Z0-9_-]+)-edit$ artikel.php?id=$1&create=edit
RewriteRule ^itm([a-zA-Z0-9_-]+)-create$ artikel.php?id=$1&create=created
RewriteRule ^itm([a-zA-Z0-9_-]+)$ artikel.php?id=$1 [QSA]
RewriteRule ^a/([a-zA-Z0-9_-]+).html$ index.php?id=$1
RewriteRule ^b/([a-zA-Z0-9_-]+)/(.*?)$ kate.php?id=null
ErrorDocument 404 /index.php?error=pagenotload

Related

htaccess /en works normal but /en/ gives page cannot be found

when browsing www.mywebsite.com/en or www.mywebsite.com/fr it works fine, if browsing with / at the end of any, it gives page cannot be found
i'm using the htaccess code below:
RewriteOptions inherit
RewriteEngine on
AddDefaultCharset UTF-8
Options -Indexes
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
RewriteRule ^fr/(.*)$ $1.php
RewriteRule ^en/(.*)$ $1_en.php
Try replacing
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
With
RewriteRule ^fr/?$ index.php
RewriteRule ^en/?$ index_en.php

Need help writing htaccess rule

Currently my localhost URL is like localhost/apnaujjain/page.php?page_id=1&action=contacts
Now I want to write a rule so that when I go to above url it just rewrite the url like localhost/apnaujjain/contacts.html
See it should convert .php into .html without affect page content.
Until now I've tried
Options +FollowSymLinks -MultiViews
RewriteEngine on
#RewriteBase /
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.php?page_id=1$&action=2$
RewriteRule ^(.*)\.php $2.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]
But it's not working.
You can use this code in /apnaujjain/.htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /apnaujjain/
# redirect localhost/apnaujjain/page.php?page_id=1&action=contacts to
# localhost/apnaujjain/1/contacts.html
RewriteCond %{THE_REQUEST} \s/+.+?\.php\?page_id=([^\s&]+)&action=([^\s&]+) [NC]
RewriteRule . %1/%2.html? [R=301,L]
RewriteRule ^([^/]+)/([^.]+)\.html$ page.php?page_id=$1&action=$2 [NC,L,QSA]

Hide the directory in url using .htaccess

I've the links as follow:
localhost/a/site/watch/contact/
localhost/a/site/details/about/
where .htaccess file is in site folder
All I want to do is remove watch and details from the url like:
localhost/a/site/contact/
localhost/a/site/about/
Update
#Options -Indexes
#Options +FollowSymLinks
RewriteEngine On
#Exclude myadmin directory from the second level links
RewriteRule ^(myadmin)(/.*)?$ - [L]
RewriteRule ^(source)(/.*)?$ - [L]
ErrorDocument 404 /404.html
RewriteRule ^([a-zA-Z0-9_\-]+)/?$ index.php?task=$1 [L]
#Redirect 2nd level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2 [L]
#Redirect 3rd level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2&page=$3 [L]
#Redirect 4th level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2&title=$3&page=$4 [L]
I've tried following but this doesnot work
#RewriteRule ^/(.*)$ /watch/$1
RewriteBase /a/site
RewriteCond %{HTTP_HOST} ^/watch/
RewriteRule /(.*) /watch/$1 [QSA,L]
RewriteRule /(.*) /details/$1 [QSA,L]
RewriteRule /(.+) /watch/$1/index.php [NC,L]
RewriteCond %{THE_REQUEST} \ /+watch/
RewriteRule ^watch/(.*)$ /$1 [L,R=301]
Insert these 2 rules just below RewriteEngine On line in /a/site/.htaccess:
RewriteRule ^(contact)/?$ index.php?task=watch&slug=$1 [L,QSA,NC]
RewriteRule ^(about)/?$ index.php?task=details&slug=$1 [L,QSA,NC]

Create SEO Friendly URLS doesn't work (.htaccess)

I created an htaccess i want to rename all extension .php files to .html
i put
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]
and it work fine.
Now i want to rename nettoyage-detail-bureaux.php?id=21 to nettoyage-detail-bureaux-21.html
so i add
RewriteRule ^nettoyage-detail-bureaux-([0-9]+)\.html$ nettoyage-detail-bureaux.html?id=$1 [L]
it doesn't work.
Any idea ?
I think you might have a typo at the end where you have .html?id=$1 it should be .php?id=$1
So try this.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^nettoyage-detail-bureaux-([0-9]+)\.html$ nettoyage-detail-bureaux.php?id=$1 [L]
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]

rewrite flag [L] is not working

This is my .htaccess file i just want to rewrite the page from one url to another.But it moved 404 page
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteRule ^([^/]+)/article/([^/]+)$ /index.php?option=com_vendorsearch&view=article&title=$2 [L]
RewriteRule ^([^/]+)/polls/([^/]+)$ /index.php?option=com_vendorsearch&view=polls&id=$2 [L]
RewriteRule ^([^/]+)/coupons/([^/]+)$ /index.php?option=com_vendorsearch&view=coupons&id=$2 [L]
RewriteRule ^([^/]+)/images/([^/]+)$ /index.php?option=com_vendorsearch&view=images&id=$2 [L]
RewriteRule ^([^/]+)/videos/([^/]+)$ /index.php?option=com_vendorsearch&view=videos&id=$2 [L]
Probably you need your first rules as:
RewriteRule ^[^/]+/articles/([^/]+)/?$ /index.php?option=com_vendorsearch&view=article&title=$1 [L,QSA,NC]

Resources