Forum Moderators: phranque

Message Too Old, No Replies

shorten url

from /wp/ to just / (root)

         

skyzer

5:11 pm on Mar 10, 2010 (gmt 0)

10+ Year Member



I've looked for many many tutorials tried some of them, but there still wasn't quite anything like this.
I have my website uploaded to /wp/ directory (wordpress blog), so without moving my directories and files to root directory i'd like to make that my address bar will show /index.php etc, but not /wp/index.php
It's good for SEO and visitors also.

I'm sure it should be some short rewriterule, like
RewriteRule ^wp /

but this doesn't work :(
any help?

g1smd

7:02 pm on Mar 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to change the links on the pages to the new format. It is links that define the URLs that visitors see and use.

Once you have done that, you need a rewrite to connect those URL requests to the real internal folder location.

Additionally, do not link to
/index.php
like that. The filename may be
index.php
but the URL used to access that content should be just '
/
'.

Each rule also needs the
[L]
flag.

You also need to make sure that requests for robots.txt and other such files are still correctly handled, i.e. the RewriteRule should probably NOT rewrite all URL requests arriving at the server.


Your existing rule is exactly backwards. It says for any URL request beginning with
example.com/wp
serve content from an index file in the root of the site (i.e. serve content from the file at
/index.php
or
/index.html
etc).

skyzer

2:59 pm on Mar 13, 2010 (gmt 0)

10+ Year Member



okay thanks, got it
now its

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

and it works as i wanted plus wordpress does other job, no file names or get parameters appear, only "pretty url's" like /category/job/

g1smd

8:05 pm on Mar 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Look to a recent WebmasterWorld thread for some code that improves the efficiency of the Wordpress rewrites by several fold.