Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

.htaccess - Url rewriting not working with wordpress unless using [R]

I have a Wordpress installation on my website on the folder blog-ita/. Now, I'd like to add a rewrite rule to allow accessing it from website-name/blog/.

I used this rewrite rule:

RewriteRule ^website-name/blog/(.*)$ blog-ita/$1

Now, this works if I add the [R] tag, but otherwise I get the 404 not found page from wordpress instead of the page I wanted to see.

How can that be? How can I make this work without the [R] flag?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can follow this guide from Wordpress to get Wordpress to work in a different directory than wordpress is actually located.

You want to install wordpress in the blog-ita directory. You want the url to show website-name/blog instead. Follow the following steps:

  1. Go to the "General" panel in your admin section and change/check the following boxes, then save the changes:
    • Site address (URL): Change this to http://example.com/website-name/blog
    • Make sure that WordPress address is correctly configured as htttp://example.com/blog-ita.
  2. Copy the index.php and .htaccess files in /blog-ita and paste them in /website-name/blog. You need to copy, not move.
  3. Open the index.php file in /website-name/blog in your favourite text editor and change the line that says require( dirname( __FILE__ ) . '/wp-blog-header.php' ); to point at the same file in the directory where wordpress is installed. In this case it should be changed to require( dirname( __FILE__ ) . '../blog-ita/wp-blog-header.php' );. Save the changes.

From this point on, wordpress should be available at http://example.com/website-name/blog/. The admin section is only available at the actual installation directory (/blog-ita/admin).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...