3

I am trying to change a URL, in my htaccess I have added this line:

RewriteRule ^/about/$ /site/about_us/

After adding this, if I hit my URL http://mydomain.com/about/ it gives me 301 moved permanently and redirects to http://mydomain.com/site/about_us/

My htaccess file:

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

# END WordPress

enter image description here

Headers:

Response Heades:
HTTP/1.1 301 Moved Permanently
Date: Wed, 18 Jun 2014 09:42:45 GMT
Server: Apache/2.4.4 (Win64) PHP/5.4.12
X-Powered-By: PHP/5.4.12
X-Pingback: http://soller.local/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Location: http://soller.local/site/about_us/
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8


Request Heades:
GET /about/ HTTP/1.1
Host: soller.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: wp-settings-time-1=1393072512; wp-settings-1=libraryContent%3Dupload%26editor%3Dtinymce%26hidetb%3D1; wp-settings-time-47=1390228546; wp-settings-time-877=1392096718; wp-settings-time-2579=1393680813; wp-settings-time-2578=1393427211; wp-settings-time-106=1394689670; wp-settings-time-4965=1396012806; PHPSESSID=28tioc16rbc3314br3smf9djv7; wordpress_logged_in_3bbc4cdbbb4e6dcd108616247c041571=nirajmchauhan%40gmail.com%7C1403246168%7C08fbbba723e8d02b102a50fb5d0dee38; last_navigator_url=http%3A%2F%2Fsoller.local%2Fsite%2Fprofile%2Fmy-assessments%2F; url_route_slug=%2Fniraj; current_navigator_url=http%3A%2F%2Fsoller.local%2Fniraj
Connection: keep-alive
Disha
  • 776
  • 9
  • 19

1 Answers1

0

You should remove the [PT] rewrite flag. You can learn more about rewrite flags here: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_pt

ADDITION

Also you might need to move your rewriterule before the wordpress rules. your code will look like this

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

# END WordPress
Maai
  • 359
  • 3
  • 12
  • sorry, remove the first slash in the matching string - should be: RewriteRule ^about/$ /site/about_us/ [L] – Maai Jun 18 '14 at 08:14
  • I just did, it's working: http://lovegracy.com/about/ - masked url existing file: http://lovegracy.com/site/about_us/ what error are you getting? If you want to this to work this in a url without a slash at the end update the matching string to this: ^about/?$ – Maai Jun 18 '14 at 08:29
  • To what url is it redirectign – Maai Jun 18 '14 at 08:50
  • When hitting this URL `http://soller.local/about/` it is redirecting to `http://soller.local/site/about_us/`. Tried removing last slash after `about`, but not working – Disha Jun 18 '14 at 08:53
  • That should work try checking if youre editing the right htaccess and see if there are similar redirects – Maai Jun 18 '14 at 09:23
  • Could you please post the whole header response as well – Maai Jun 18 '14 at 09:36
  • I have edited my question, please check headers of response and request – Disha Jun 18 '14 at 09:46
  • The 301 redirect is happening in wordpress. In what folder your wordpress install and .htaccess file are? Could post your whole current .htaccess file – Maai Jun 18 '14 at 09:52
  • also, is the about/ an existing folder? – Maai Jun 18 '14 at 09:58
  • The folder structure is `wamp/www/soller/wp-content/themes/mytheme/web/` and please check updated htaccess file above. Htaccess file is stored inside `soller` folder. `about` is not a folder. – Disha Jun 18 '14 at 10:00