1
votes

Thanks for helping me resolve this issue. I have urls looking like:

http://local-host/enc/?aya-bi-aya=aya-6&assurah=an-nisa&attab=attakhrij

The goal is to make them appear like:

http://local-host/enc/aya-bi-aya/an-nisa/aya-6/attakhrij

The rules I am defining in my .htaccess are:

# BEGIN WordPress
RewriteEngine On
RewriteRule   ^aya-bi-aya/(.+)/(.+)/(.+)$   ?aya-bi-aya=$2&assurah=$1&attab=$3   [L]
# END WordPress

I receive a 404 page. What am I missing?

2
Is this htaccess file in your /enc/ directory? - Jon Lin
My htaccess file is in /enc/. Thanks for your time. @JonLin - Adib Aroui

2 Answers

1
votes

I just updated this rule as per the new info shared by you:

RewriteEngine On
RewriteRule ^aya-bi-aya/([\w-]+)/([\w-]+)/([\w-]+)/?$  ?aya-bi-aya=$2&assurah=$1&attab=$3 [L]

I'm using a character class \w which is equivalent to [a-zA-Z0-9_]. Makes the rule more readable and /? at the end allows your rule to work with the URLs that don't have a trailing slash.

1
votes

Everything after the "?" in the original request (i.e., the "query string") is not part of the main URL.

However, you can access the query string via:

RewriteCond %{QUERY_STRING} ....

So something more like this:

RewriteEngine On
RewriteCond /enc/
RewriteCond %{QUERY_STRING}     ^aya-bi-aya=([^&]*)\&assurah=([^&]*)\&attab=([^&]*)$    
RewriteRule   .*  /enc/aya-bi-aya/%1/%2/%3   [L,R=301]*

The L = last, R = redirect to change the displayed URL in the user's browser