Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Having trouble combining two Rules in htaccess file

Featured Replies

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)

# -FrontPage-

RewriteEngine On
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]p

# BEGIN WordPress

# END WordPress

The .htaccess has the following.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

#END WordPress

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.