简体   繁体   中英

.htaccess RewriteRule 404 Not Found

I'm having issues with .htaccess RewriteRule. all I'm trying to do is rewrite this url - www.example.com/public/?q=admin to - www.example.com/public/admin

but now when I go to this url www.example.com/public/admin it says not found.

but this url is working ww.example.com/public/?q=admin

here is my .htaccess code

Options All -Indexes

<FilesMatch "(config|.+\.html)\.php">
    deny from all
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_URI} !\.(bmp|cgi|css|flv|gif|ico|jpe?g|js|png|swf|xml)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule (.*) ?q=$1&%1 [L,QSA]
</IfModule>

Does anyone know to help?

UPDATE This script installed inside a subdomain and a sub folder like this http://subdomain.maindomain.com/comingsoon/ coming soon is the root folder http://subdomain.maindomain.com/comingsoon/public is another folder where placed .htaccess file.

I'm using mini php framwork called Swiftlet

https://github.com/AliasIO/Swiftlet

Ok, so after your update, try this :

RewriteBase /comingsoon/public
RewriteRule ^(.*)$ /?q=$1 [L,QSA]

You can use this rule in your .htaccess for your required url.

RewriteRule ^public/(.*)$ public?q=$1 [L,QSA]

UPDATE 1:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain.com
RewriteRule ^public/(.*)$ http://subdomain.domain.com/comingsoon/public?q=$1 [L,NC,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM