2

I need help in WordPress .htaccess. My projects name is Project this is WordPress and onepage website, inside this I have one more project that is built in CI named app. What I want is, if someone enters anything after /, then get content from CI App project. I do not want to redirect user to http://example.com/app/<anything>. As i said wordpress project is one page, so when i click on navigations i got !# like characters in url.

http://example.com/<anything>

My current .htaccess is

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

Is it possible?

0

Since your WordPress site is just a one-page site, this is served from the single URL http://example.com/. You then want http://example.com/<something> to be internally rewritten to http://example.com/app/<something>.

You can add the following mod_rewrite directives before your existing WordPress directives (ie. WordPress front-controller) in your root .htaccess file:

# Route all URL-paths (of 1 or more characters) to CI app
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule (.+) /app/$1 [L]

# WordPress directives start here...
:

The RewriteCond directive that checks against the REDIRECT_STATUS environment variable ensures that only initial requests are rewritten, as opposed to internal rewrites to index.php by WordPress.

The RewriteRule pattern (.+) ensures we only match URL-paths longer than one character, missing the document root - which is passed through to WordPress.

  • not working, got object not found – Manoj Bist Dec 3 '17 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.