htaccess force trailing slash with further conditions

I have an existing htaccess-file that redirects to a subfolder. It is necessary to have an trailing slash.

I have add a rule that redirects to an url with a trailing slash, but since then the other rules are never met.

RewriteEngine On

RewriteRule ^(.*)$ /$1/ [C,R=302] #301 when everything works fine :)

RewriteRule ^app/(.*)$  webapp/PNJ/client/frontend/$1  [QSA,L]
RewriteRule ^pnj_be/(.*)$  webapp/PNJ/client/backend/$1  [QSA,L]

The C in the first rule should chain the rules, but I don’t know why the rules are never met. If I write manually the rules are accepted. If I dont’t add the trailing slash, I will get redirected to the URL with the correct url, but then the browser can’t find any files.

Can anyone explain why this doesn’t work? Or give a hint, what the right solution is?

Url rewriting code in htaccess file [on hold]

This is my orginal link:

and i required that url has to be in this format.
am passing two id (id1/id). am new to htaccess , so doesn’t know anything regarding this if you would help thouroughly. it will be more helpful more for me to work on further projects.

this is my htaccess code. am apearing that url perfectly . but errors am occuring.
RewriteEngine on

#To externally redirect /blog-single?id1=foo&id=bar to /mochBlog/bar
RewriteCond %{QUERY_STRING} ^id1=([^&]+)&id=(.+)$ [NC]
RewriteRule ^.*$ /MCoH-Blog/%1/%2? [R,L]
#To internally redirect /mochBlog/bar to /blog-single?id1=foo&id=bar
RewriteRule ^MCoH-Blog/([^&]+)/(.+)$/blog-single?id1=$1&id=$2 [L]

and this the Error am Occuring

Object not found!
The requested URL was not found on this server. If you entered the URL 
manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404
Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28

i tried it in my localhost

convert rules from htaccess to nginx

hope somebody can help me, in transforming my apache htaccess rules to nginx config

  1. Removing the .php from the url’s, so url: “/contac”t displays the file contact.php

  2. Make this paths use their respective php file, for example:

“/products” shows the file products-all.php

“/products/some-category-name” shows the file products-cat.php

“/products/some-category-name/product-name?id=89” shows the file products-detail.php

I tried searching everywhere, but couldn’t fine the correct answer, appreciate any help


how to remove query parameter change user define url using php or .htacesss [on hold]

Using PHP or JavaScript, then change url format present my url like this

but i will change my url for seo purpose i need below any possible one format sir


but it’s working not geting query parameter css also not working i need best one using is ” ” please clear my issue sir help me

Using .htaccess to forward all routes except one to home page for react-router v4

I am using create-react-app and react-router v4. I have a site with many paths, however, one path is a literal path to a folder called assets where images, icons, etc are served.

The site structure is like this:

.. [root]
assets [dir]
index.html [file]

However, I have many virtual URLs that point to the index.html of the CRA app. How can I use .htaccess to forward all requests except those in assets to the index.html file?

Or, is there a better/best practice for handling this scenario?

I have tried this but it gives a 500 error.

Options -Indexes
RewriteEngine On

# Forward to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteRule ^{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^{REQUEST_URI} [R,L]

# Forward to React
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(assets)(/|$)
RewriteRule ^(.*)$ / [L,QSA]

How to make separate users and passwords in .htpasswd and make them redirect into another directory with .htaccess?

I would like to have assistance on this project that i am trying to make. I am trying to use .htaccess and .htpasswd to handle the directory redirections and i would like to know what is the code or how to fix/tweak mine to make searate users like:


And have it to only have access to the files:

SamSmith > ControlPanel/User/SamSmith

JaneSmith > ControlPanel/User/JaneSmith

Here is the codes:

[ .HTPASSWD File ]


[ .HTACCESS File ]

AuthType Basic
AuthName "restricted"
AuthUserFile C:\wamp64\www\Secure-TTS-Link\.htpasswd

<Files "ControlPanel\User\RediPanda">
Require user RediPanda

<Files "*">
Require user Admin



The HTACCESS file and the HTPASSWD is located in the Secure-TTS-Link directory

I use WampServer to host this and thanks for helping me! 🙂

How to check if the main domain matches a certain domain and then redirect the request in .htaccess?

What I want to accomplish is that when the user tries to visit the site with url like the following :

so it should redirect to :

With the whole URI and then if user visits the following url as the following : OR

so it should redirect to :

I have tried with the following code but it redirects all requests to as :

# Avoid use of HTTPS for TEST SERVER
RewriteCond %{HTTPS_HOST} ^ [NC,OR]
RewriteRule ^(.*)$$1 [L,R=301,NC]

# Redirect all www or non www to https
RewriteCond %{HTTPS}::%{HTTP_HOST} ^off::(?:www\.)?(.+)$
RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]

NOTE : I want to redirect with the whole URI not just to the main domain links.

htaccess handling of non-existent paths via script

I’d like to be able handle nonexistent paths via script processing.
I’m currently doing this through .htaccess

RewriteEngine On
RewriteBase /SomeSubFolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ \#$1 [L,R=301,NE]

The idea here is to take the non-existent part of the path and convert it to a hash.
So that




The hash then gets interpreted either via JS or PHP.

However quirky, it’s been working. Perhaps there’s a more elegant way to do this?
I’d like to also include an http-to-https conversion in the above .htaccess, but so far haven’t figured out how to do both.

I suspect there’s a better way of doing all of the above.

Images on WordPress Multisite is not showing up

I am having issues on a WordPress multisite driven site, all images would not show up and it appears that this is caused on a misconfiguration of the .htaccess file. Below is the content of the .htaccess

RewriteEngine On 
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule .* - [R=403,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
#uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
ErrorDocument 403 /maintenance.html
ErrorDocument 404 /maintenance.html
ErrorDocument 500 /maintenance.html

How do I rewrite rules for multiple apps under one domain?

I have different apps that I wanted to put under one domain name. I want them to look like this on the url:

My document root folder is /var/www/ And all the apps resides under /var/www/

How do I rewrite the rule with mod_rewrite.c inside virtual host, and also hide the index.php?