Mobile app version of vmapp.org
Login or Join
Bryan171

: Write htaccess rewrite rule which should be point to a directory which is not existing in app directory structure I need to write a rewrite rule so that the url should be point to a directory

@Bryan171

Posted in: #Htaccess #Redirects #WebHosting #Wordpress

I need to write a rewrite rule so that the url should be point to a directory which is not existing in the application directory. In WordPress all admin process/code in wp-admin, so someone try to login, the url in clients browser will rewrite to example.com/wp-admin/*php. I need to avoid that, I wish the browser should show the directory ec-admin instead of wp-admin. That is example.com/ec-admin/*php
This should achieve only by editing htaccess instead of editing entire code.

Here is my .htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteRule ^wp-admin/(.*) /ec-admin/ [R=301,NC,L]


But now its showing file not found error, is there anyway to fix it?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Bryan171

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

Sadly with most content management systems its not always as easy to make a simple rewrite in the .htaccess file since the paths are driven from settings in the php and that of your database, this can cause looping effect or a 404 error.

Generally rewriting urls from one from to another while keeping the query string intact will look something like:

RewriteRule ^admin/(.*?) ec-admin/ [QSA]


Notice the [QSA] this will keep the query string in tact while renaming admin to ec-admin.

If you find that your website is having unnecessary additional redirect hops, a loop or a 404 error then its likely because WordPress is driving the permalinks as mentioned, thankfully WordPress is extremely popular and there's dozens of plugins that will allow you to edit permalinks in the dashboard or alternatively rename the admin folder for security or other reasons!

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme