How to ignore htaccess folder from wordpress htaccess - php

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]

Related

htaccess - add custom rewrite to standard wordpress rewrites

i have a wordpress website
i have uploaded some of my php code at the root of my web where wordpress is installed.
i want to open those page directly.
they open if # www.example.com/newcode.php
but i want to open them like www.example.com/newcode (without extension .php)
the problem is when i put some .htacess code to achieve this, all wordpress pages stops and shows error404 not found and if i remove htaccess code then i cant open my own newcode.php page without extension
i tried to put this code in htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^\.]+)$ $1.php [NC,L]
but doesnt work...
this is my wordpress .htaccess (automatically created by wordpress)
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^\.]+)$ $1.php [NC,L]
</IfModule>
# 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
id have more files like newcode.php and some folder in which there are more code files and i want all of them to open like this
i want both wordpress pages as well as my new code page to open without any extension and i cant put newcode.php in seperate folder and make another htaccess for that specific folder
This is documented pretty clearly - especially in this case where you don't even need any regexp knowledge. Simply replace everything before # BEGIN WordPress with:
RewriteEngine On
RewriteRule /newcode /newcode.php [L]

.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
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]

Wordpress .htaccess file with current system

Okay, so I'll explain this to the best of my abilities. I have Wordpress files running from a separate directory "_esSite" in the root folder. To do this, I must update my .htaccess file with some code from Wordpress. HOWEVER, the code in the .htaccess file from Wordpress is now not allowing my real directories open properly because it tries to run it through Wordpresse's index.php. Basically, if the folder/directory actually exist on the server, I want it to ignore the Wordpress code in the .htaccess file. Hope that makes sense.
Example case:
If I have a folder on my server named "/xyz/", then I want the htaccess file to basically read everything ABOVE "# BEGIN WordPress" in the htaccess file.
If I enter "/abc/" and the folder doesn't exist, I want it to read everything BELOW the "# BEGIN WordPress".
Please let me know if you have any questions and I'll try to clarify. Below is my current htaccess file. Thank you very much!
DirectorySlash Off
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# add a trailing slash to directories
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=302]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)/?$ _client.php?var1=$1&var2=$2&var3=$3&var4=$4&var5=$5 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)/?$ _client.php?var1=$1&var2=$2&var3=$3&var4=$4 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ _client.php?var1=$1&var2=$2&var3=$3 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/?$ _client.php?var1=$1&var2=$2 [L,QSA]
RewriteRule ^([\w-]+)/?$ _client.php?var1=$1 [L,QSA]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /_esSite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /_esSite/index.php [L]
</IfModule>
# END WordPress

Wordpress .htaccess file on root creating issues for sub directories

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

.htaccess - works only with index.php/ not with /

I have an test project in sub directory (G:/wamp/www/test) which has only index.php and .htaccess
I tried to make friendly urls by adding RewriteRule to .htaccess like this:
RewriteEngine on
DirectoryIndex index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule ^/*$ index.php
This worked on all other projects but it is not working on this one. When I want to access an URL like this:
http://localhost/test/TESTING_URL I am getting default 404 Not Found page. However, if I go like this: http://localhost/test/index.php/TESTING_URL - it works.
Apache error log is giving me the following error:
File does not exist: G:/wamp/www/test/TESTING_URL
The following worked for me:
RewriteEngine on
RewriteBase /test/
DirectoryIndex index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule ^/*$ index.php
Make sure that this .htaccess file is in the directory test and that there aren't any conflicting rewrite rules in any .htaccess file at a higher level.
Otherwise the only difference is the addition of the RewriteBase line.

Categories