Reputation: 125
I have url like this
mydomain.com
But when I access it, I want rewrite it to this url
mydomain.com/news
In other case, I want it like this
mydomain.com/read/1 -> mydomain.com/news/read/1
mydomain.com/view?cat=sport -> mydomain.com/news/view?cat=sport
My code is like this
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/news/$1 [QSA,NC]
But it still not work. It is not add "news" in next url segment. Please suggest how I can write a rewrite rule for this in .htaccess? I am sorry about my English
Upvotes: 1
Views: 379
Reputation: 41219
Replace your code with the following :
RewriteEngine on
RewriteRule !^news /news%{REQUEST_URI} [L]
Upvotes: 1