I have a page as follows.
www.mysite.com/about.php
I want this to be set in the htaccess file so that it looks like below.
www.mysite.com/my-keyword-here
Please help me.
Thanks in advance.
Sam
Add this to the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?my-keyword-here$ /about.php [L]
So now if you enter http://www.mysite.com/my-keyword-here in your browser's URL address bar, you will be returned the content of /about.php.
Related
I am trying to rewrite URLS in my website but unable to do so.
I am using Lightspeed in Cyberpanel. The .htaccess code I used is:
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
What my url looks right now: mysite.tld/index.php?a=2322
What I want to look it like: mysite.tld/2322
Thanks in advance!
I have a multi language website in code igniter with uses prefix in the URL to define the language. Works great but there is a problem when going to the home page.
The default URL is
localhost:8888
but it should be
localhost:8888/index.php/EN/welcome
I tried redirecting in the controller but that didn't work.
Any ideas on how to fix this problem?
Thanks a lot
First of all you must create a .htaccess file in your root path. File content like this;
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
You can edit your route file like this;
$route['(:any)/(:any'] = 'IndexController/getPage/$1/$2';
$route['(:any)'] = 'IndexController/index/$1';
$route['default_controller'] = 'IndexController';
Route 1: Your sub page. First parameter is language, second parameter is page url
Route 2: Your home page. Parameter is language.
Route 3: Default home page in your main language.
I have a slight issue. I have configured my default controller as :
c$route['default_controller'] = 'news';
so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller.
Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?
There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:
Removing the index.php file
Using the following rewrite code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also, there are many similar questions to yours, have a look at these questions from the search:
Search query on removing index.php in Codeigniter
You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite
I have a site where my pages are generated dynamically. I want to change the url from:
http://www.mydomain.com/library.php?id=13
to something like:
http://www.mydomain.com/13.html
I am using this Rewrite Rule:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /library.php?id=$1 [L]
Unfortunately it doesn't work. When I click on the link the page goes to this url:
www.mydomain.com/library.php?id=13
But the strange part is when I browse to www.mydomain.com/13.html the link is working.
What am I missing?
You need to change the links that are generated in the library.php files to your new defined format :)
I have link www.mydomain.com/page.php?pageid=10
I want to change into www.mydomain.com/10
please help me this guys.
Put this in a .htaccess file, and place it in the webroot.
RewriteEngine On
RewriteRule ^([0-9]+)$ page.php?pageid=10