i want to change this URL
domain.com/adsbycat/sub_category.php?category=car-and-buses&category_id=1&sub_category=Car
to
domain.com/car-and-buses/1/Car
i write this code to do this
RewriteEngine On
RewriteBase /domain.com/
RewriteRule ^adsbycat/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3
but when i request for new URL it showing 404 not found. please fix this code.
Have this rule in site root .htaccess to rewrite domain.com/car-and-buses/1/Car:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/[^/]+/(.+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3 [NC,L,QSA]
Related
I have this simple .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shop$ /apps/shop
So it should redirect this url
http://192.168.0.221:8085/shop
to that url
http://192.168.0.221:8085/apps/shop
But the server only gives Error 404.
Can't get it why?
The htaccess I edited was not in the document root, thanks to #arkascha for this hint.
i've encountered the following problem:
The .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule view/^(.*)$ view.php?id=$1 [L,QSA]
Is not rewriting my urls
The friendly URL should be like this
https://domain.tld/view/1
And the original url should be rewritten like this:
https://domain.tld/view.php?id=1
The result of the htaccess above is a 404.
Try
RewriteRule ^view/(.*)$ view.php?id=$1 [L]
I am trying to change the URL from:
/chat/create?ref=9dsda to /chat/create/refer/9dsda
However, everytime I go to the lather, I get the error:
Not Found: The requested URL /chat/create/ref/9dsda was not found on this server.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/create/refer/([^/]+) /create?ref=$1
I've tried several things such as adding RewriteBase /chat/ without success.
If your htaccess is in the root ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^chat/create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
If it is inside the /chat dir ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
htaccess is a per-directory context so you don't need to match against the folder that the htaccess is in.
I would like to redirect (mod_rewrite) the URL that user enters to another.
User enters:
www.example.com/text
And the URL to display should be:
www.example.com/index.php?test
I have this .htaccess file, but it does not work (I get 404 error):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ ?page=$1 [L,QSA]
Where am I wrong?
Thanks everyone
When I go to http://www.example.com/youtube/detail/abvcde in my browser, I want to internally rewrite the url to http://www.example.com/youtube/detail.php?id=abvcde. I tried to do this with the following .htaccess, but it gives a 404 error.
Currently my .htaccess looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
Put the following code in a htaccess file in server root directory:
RewriteEngine On
RewriteRule ^youtube/detail/(.+)$ youtube/detail.php?id=$1 [L]
You can put this code in your /youtube/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /youtube/
RewriteRule ^detail/([^/]+)$ detail.php?id=$1 [L]