'How to redirect to an alias folder using htaccess?
I have a url http://www.example.com/chatroom/chats.php?chat=hey dear
I want a url to be http://www/example.com/chatroom/chats/hey dear
where chatroom is an alias folder.
my apache document root is pointing to a specific folder as DocumentRoot
/var/www/html/myweb
I am trying like
RewriteEngine on
RewriteBase /
RewriteRule ^chatroom/([A-Za-z0-9-]+)/?$ chats.php?chat=$1 [NC]
Its saying
404 not found.
Solution 1:[1]
Set QSA flag for your rule and try
RewriteRule ^chatroom/(.*) chats.php?chat=$1 [QSA,L]
QSA - Query String Append
Solution 2:[2]
You need to place a .htaccess file in chatroom folder with the following content.
Options +FollowSymLinks
RewriteEngine on
RewriteRule chats/(.*) chats.php?chat=$1
Or the following if placing in root folder
RewriteEngine On
RewriteRule ^([^/]*)$ /chatroom/chats.php?chat=$1 [L]
Here are some tools which might help you to generate the such code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vijay Wilson |
| Solution 2 | Glorfindel |
