June 3, 201511 yr I created a Rule in my HTACCESS file, to hide a sub-folder. RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php [NC,L] The first rule removes all file-extensions : php The second rule will hide the folder "Project" from the URL Both these rules are working perfectly. However, when I tried to add a third rule, to hide another folder, it failed. This second folder (Rolan) is in the same location as the "Project" folder, so I assumed that it should work simply by copy-pasting the second rule, and then adding a PREFIX to the beginning of the third rule : RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [NC] RewriteRule ^ /%1/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ $1/Project/$2.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^gagoo/([^/]+)/([^/]+)/?$ $1/Rolan/$2.php [NC,L] I added the prefix "gagoo" to the third rule. Also, I removed the [NC,L] from the end of the second rule, and placed it at the end of the third rule. Then, in my PHP code, I wrote the URL as follows : www.example.com/gagoo/Rolan/file_name Both the first and second rules are still working. But, for the third rule, I am getting a "FILE NOT FOUND : 404" error. The thing is : I wrote a JavaScript code, which opens "file_name" in a "New Window". (Still, I doubt that this could be the reason for the problem)
June 9, 201511 yr # -FrontPage- RewriteEngine OnRewriteBase /#RewriteRule ^index\.php$ - [L] # uploaded filesRewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-adminRewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^ - [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]RewriteRule . index.php [L]p # BEGIN WordPress # END WordPress The .htaccess has the following. # BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule> #END WordPress
Create an account or sign in to comment