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
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]
Ok, so after your update, try this :
RewriteBase /comingsoon/public
RewriteRule ^(.*)$ /?q=$1 [L,QSA]
Related
I have this .htaccess file in Wordpress. It's located at /file_name/ (web root). I need to exclude a folder (booknow) from the rewrite engine.
I've tried this code:
RewriteRule ^/booknow($|/) - [L]
My Full .htaccess code given below:
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /file_now/
RewriteRule ^/booknow($|/) - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /file_now/index.php [L]
</IfModule>
#END WordPress
I tried this code but it didn't work.
Firstly assuming the br in your code are mistakes and not that you're writing HTML inside a .htaccess file.
The pattern in your rewrite rule has both a slash in the RewriteBase and the RewriteRule, so it's looking for something like /file_name//booknow/ You should instead type:
RewriteRule ^booknow($|/) - [L]
I got my own answer. I create a .htaccess File in WordPress directory booknow folder then I added below code to .htaccess file:
RewriteEngine on
RewriteCond %{file_now/booknow} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
ErrorDocument 404 /file_now/booknow/404page.php
Now My Booknow folder is properly working.
Try this code:
RewriteRule ^(directory_name)($|/) - [L]
I am writing a program and run it locally with xampp. the full path to the program is http://192.168.101.103:7777/WeltesMaft/index.php
I am writing a .htaccess in C:\xampp\htdocs\WeltesMaft\
containing this
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule .* http://192.168.101.103:7777/WeltesMaft/%1 [L]
but somehow my htaccess doesnt work. it still showing like this
http://192.168.101.103:7777/WeltesMart/_resources/main.php
which is in index.php i am including main.php. So when user enters index.php, it will redirect to main.php in an instant.
I want to hide it so that the url looks like this,
http://192.168.101.103:7777/WeltesMart/
Please help me what am i doing wrong here...
You can use this code also.....
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ _resources/main.php/$1 [L,QSA]
</IfModule>
Change RewriteBase to your directory name and change the htaccess rule as following and try again:
RewriteEngine On
RewriteBase /WeltesMaft
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule / index.php [L]
I have this very critical issue of Wordpress messing up with my website's sub directories. Following is the very detailed info.
I have a wordpress installed on root . Unfortunately, I cannot move it to a folder.
I have 3 other custom PHP applications in following 3 respective directories
a. /client
b. /console
c. /order
Following are the .htaccess code for each of these directories
.htaccess code for /client folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^orders$ orders.php
RewriteRule ^profile$ profile.php
RewriteRule ^orders/pending$ orders.php?type=pending
RewriteRule ^orders/completed$ orders.php?type=completed
RewriteRule ^logincheck$ logincheck.php
RewriteRule ^login$ login.php
RewriteRule ^logout$ logout.php
RewriteRule ^ticket/open$ support-ticket-open.php
RewriteRule ^ticket/open/step/2$ support-ticket-open-2.php
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
.htaccess for /console folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^orders$ orders.php
RewriteRule ^services$ services.php
RewriteRule ^service/add$ add-service.php
RewriteRule ^coupons$ coupons.php
RewriteRule ^markups$ markups.php
RewriteRule ^markups/view/maincat$ markups.php?view=maincat
RewriteRule ^markups/view/markup$ markups.php?view=markup
RewriteRule ^markups/view/option$ markups.php?view=option
RewriteRule ^order/add/step/(\w+)$ add-order.php?step=$1
RewriteRule ^order/add$ add-order.php
RewriteRule ^client/add$ add-client.php
RewriteRule ^clients$ clients.php
RewriteRule ^logout$ logout.php
RewriteRule ^login$ login.php
RewriteRule ^ordering/service$ service-ordering.php
RewriteRule ^ordering/markup$ markup-ordering.php
RewriteRule ^setting/markup$ markup-setting.php
RewriteRule ^setting/general$ general-settings.php
RewriteRule ^tickets$ tickets.php
RewriteRule ^ticket/open$ open-ticket.php
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
RewriteRule ^client/orders/(\w+)$ orders.php?client_id=$1 [L]
RewriteRule ^ticket/update/([\w-]+)$ update-ticket.php?ticket_no=$1 [L]
.htaccess for order folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^order$ order.php
RewriteRule ^order/([^/\.]+)/$ order.php?service=$1
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
.htaccess for Wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Now the issue is that all /client & /console folder are properly accessible. But I have a folder called /server/php/ inside /order folder. This folder seems to be inaccessible and redirects to a Wordpress 404 page. I've been trying hard. But, everything is in vain. Please lemme know what the issue can be . Also, I cannot move the Wordpress to a /wp folder. So, please advice accordingly.
Thanks in advance!
I once had an issue like this, i had a cakephp app in a subdirectory that has wordpress ass root, edit your wordpress htaccess to look like this
#Action php /cgi-php52/php
#AddHandler php52 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(order/server/php/|order/server/php/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is basically telling it to ignore Rewrite condition for the url that point to folders client, console and order
public_html/ # www.domain.com
public_html/subdomain # subdomain.domain.com
public_html/.htaccess
public_html/subdomain/.htaccess
I have a subdomain subdomain.domain.com
I have .htaccess file under public_html
This htaccess file contains this code:
Options -MultiViews
RewriteEngine On
RewriteBase /
ReWriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
ReWriteCond %{REQUEST_URI} !^/subdomain/
ReWriteRule ^(.*)$ /subdomain/$1
I need to install magento inside subdomain folder
.htaccess file inside this folder is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
</IfModule>
Magento Installed successfully, But I am facing a problem:
http://subdomain.domain.com/admin (this url works)
but when I hit http://subdomain.domain.com/index.php/admin its shows "No input file specified."
All internal URLs in admin are also throwing same error.
Please help me what wrong I put in my htaccess
Thanks in advance.
Please I need a help. I am working on a site and wants to redirect all requests to an index file while allowing access to images, css, javascripts and other documents that are not php scripts. I am working on a local server (WAMP). The problem I have is that it redirects all requests to the index file including images. Below is my htaccess rule.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myapp
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d{4})/(0?[1-9]|1[0-2])/([^/]+)/?$ app/$1-$2/$3 [R=301,L]
RewriteRule ^(.*)$ index.php [L]
</IfModule>
Is this not what you're aiming for?
RewriteRule ^(.*\.php)$ index.php [L]
You should also escape those slashes in your first rewrite rule
Thanks I have figured it out, I just modified the moved the first rewrite rule above the rewrite condition and it now working fine.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myapp
RewriteRule ^(\d{4})/(0?[1-9]|1[0-2])/([^/]+)/?$ app/$1-$2/$3 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>