1

I'm trying to change http://www.mywebsite.com/en/admin/index?page=archived

to

http://www.mywebsite.com/en/admin/page/archived/ 

I've tried a bunch of things including:

RewriteCond %{QUERY_STRING} ^page=(.+)$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/en/admin/%1? [R=301,L] 

but i have always a 404 error.

My .htaccess is into admin directory

.htaccess :

RewriteEngine On # Unless directory, remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ http://%{HTTP_HOST}/en/admin/$1 [R=301,L] # Redirect external .php requests to extensionless url RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/ RewriteRule ^(.+)\.php$ http://%{HTTP_HOST}/en/admin/$1 [R=301,L] # Resolve .php file for extensionless php urls RewriteRule ^([^/.]+)$ $1.php [L] RewriteCond %{THE_REQUEST} /index\?page=(.+?) [NC] RewriteRule ^index$ /en/admin/page/%1? [NC,L,R] RewriteRule ^page/([^/.]+)/?$ /en/admin/index?page=$1 [NC,L] 
2
  • Does the destination url you are trying to redirect to exist? Commented Feb 13, 2016 at 11:51
  • No, because i would like transform only the query string to a path url... It's possible ? Commented Feb 13, 2016 at 11:56

1 Answer 1

1

You can use the following code in admin/.htaccess:

RewriteEngine On RewriteCond %{THE_REQUEST} /index\?page=([^\s]+) [NC] RewriteRule ^ /en/admin/page/%1? [NC,L,R] RewriteRule ^page/([^/.]+)/?$ /en/admin/index?page=$1 [NC,L] 
Sign up to request clarification or add additional context in comments.

2 Comments

thank you for your support, but I still http://www.mywebsite.com/en/admin/index?page=archived in my url browser
Is perfect !! Thanks very much for your support Starkeen !

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.