Despite there being thousands of questions similar to this I was unable to make it work for this specific situation.
public_html+
|
| htaccess
| robots.txt
|
| libraries+
| | classOne.php
| | classTwo.php
|
| webroot+
| | css
| | images
| | js
| | index.php
| | article.php
The following seems to always redirect my main domain to webroot/ as I want but how do I go by deleting the webroot folder name from the url so that it looks like
www.example.com/ instead of www.example.com/webroot
I'm using the following code for this..
RewriteBase /webroot/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I've got an article.php which I'd like to edit the URL to look better for SEO.
In my real domain currently it's showing as below..
www.example.com/webroot/article.php?article_uid=33&article_title=Apple,%20Microsoft%20And%20Free%20Software
I'd like to edit the above to show like this..
www.example.com/article/id/title-goes-here
I have tried with the following code but nothing has changed at all. The only thing I don't know how is to add the slashes to the title.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^article/([^/]+)/([^/]+)/?$ webroot/article.php?article_uid=$1&article_title=$2 [QSA,L,NC]
In the htaccess file in your document root, try these rules:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /webroot/article\.php\?article_uid=([^&]+)&article_title=([^&\ ]+)
RewriteRule ^ /article/%1/%2/? [L,R=301,NE]
RewriteCond %{THE_REQUEST} \ /webroot/
RewriteRule ^webroot/(.*)$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^article/([^/]+)/([^/]+)/?$ /webroot/article.php?article_uid=$1&article_title=$2 [QSA,L,NC]
RewriteCond %{REQUEST_URI} !^/webroot/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /webroot/index.php [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.