Welcome Guest, Not a member yet? Register   Sign In
.htacess not working on links
#1

[eluser]Unknown[/eluser]
Hi geeks,

I have applied .htacess to get rid of index.php, now, it works on my home page as well as in the deeper pages on my localhost, but when I transfer them to my server, .htacess on links do not work.

My codes for links are the following:

This codes do not work on my server
Code:
<a href="&lt;?php echo base_url();?&gt;home/privacy/">Privacy</a>

While this works:

Code:
<a href="&lt;?php echo base_url();?&gt;index.php/home/privacy/">Privacy</a>

My .htacess codes are the following:

Code:
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteEngine on
RewriteCond $1 !^(trans\.php|index\.php|home|images|forum|js|cgi-bin|cgi-bin/mail\.cgi|css|links|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Please help me, thanks.
#2

[eluser]TheFuzzy0ne[/eluser]
Try changing The uri_protocol in your config.php file to QUERY_STRING, or the changing the last line of your htaccess file to
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]

or

RewriteRule ^(.*)$ index.php?/$1 [L]
#3

[eluser]TheFuzzy0ne[/eluser]
In fact, you seem to have two htaccess files in one. You should use either:
Code:
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

or

Code:
RewriteEngine on
RewriteCond $1 !^(trans\.php|index\.php|home|images|forum|js|cgi-bin|cgi-bin/mail\.cgi|css|links|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
#4

[eluser]Unknown[/eluser]
I made changes to my .htacess, but it does not work still... When I click on the links, it does not move or react on anything.
#5

[eluser]TheFuzzy0ne[/eluser]
Try using $this->config->site_url('home/privacy') instead. Also, ensure that $config['index_page'] in your config.php is set to "".

You can load the URL helper instead with $this->load->helper('url') and use site_url() which works the same way, but is less typing.
#6

[eluser]Usama Ahmed[/eluser]
Check if you server has rewrite_module enabled for apache.




Theme © iAndrew 2016 - Forum software by © MyBB