Reputation: 177
I have a folder, which is inside a subdomain folder
The Folder is
/home/user1/public_html/subdomain/user/transfer
My subdomain folder is
/home/user1/public_html/subdomain/
There this folder call user in it, and transfer is inside user.
So the hierarchy is
subdomain > user > transfer
and inside transfer folder there are 2 files
index.php and also a .htaccess
My .htaccess rule is as followed:
RewriteEngine On
RewriteRule ^transfer/(.*) /transfer/index.php-action=$1 [R=302,L]
I trying to access the page by
https://subdomain.mywebsite.com/user/transfer/cash
https://subdomain.mywebsite.com/user/transfer/credit
https://subdomain.mywebsite.com/user/transfer/AnyWord
whereby it will load the content of
https://subdomain.mywebsite.com/user/transfer/index.php?action=cash
https://subdomain.mywebsite.com/user/transfer/index.php?action=credit
https://subdomain.mywebsite.com/user/transfer/index.php?action=AnyWord
But it give me an error
Not Found
The requested URL /user/transfer/cash was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
What should I do to handle this and make my .htaccess rewrite works.
I can access
https://subdomain.mywebsite.com/user/transfer/index.php?action=cash
I just want rewrite the url to something like
https://subdomain.mywebsite.com/user/transfer/cash
And it will load the content of
https://subdomain.mywebsite.com/user/transfer/index.php?action=cash
Upvotes: 1
Views: 98
Reputation: 202
Two things,
Firstly make sure your subdomain is working correctly, forget the htaccess redirect and just put a test.html file with "Hello World" in it to make sure its working correctly.
Secondly, bring your .htaccess file back up to your root directory and your rewrite rule has a typo where you have a - instead of a ? It should read.
RewriteEngine On
RewriteRule ^transfer/(.*) /user/transfer/index.php?action=$1 [L]
You also have it setup as a redirect. I've taken this part out too, so your URL is still "masked".
Upvotes: 0
Reputation: 785866
Inside /user/transfer/.htaccess
you need to have this code:
RewriteEngine On
RewriteBase /user/transfer/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?action=$1 [QSA,L]
Upvotes: 1