Welcome Guest, Not a member yet? Register   Sign In
.htacces is not working
#1

[eluser]sonu gautam[/eluser]
Hi All,

I am trying to hide the index.php with .htaccess, but it's not working even i changed in config.php
Code:
$config['index_page'] = "";
in my config file.

i am trying to access my controller by the follwoing url

http://ip/myapp/dashboard/userpage

but i am not able to access this page it always show me "404 not found error". my htacces file is as
Code:
RewriteEngine on
Options -Indexes
RewriteBase /myapp/

RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /myapp/index.php?/$1 [L]


but if i make $config['index_page'] to $config['index_page'] = 'index.php' and try to access my page by

http://ip/myapp/index.php/dashboard/userpage

than it's working fine.

Is there something that we are doing wrong? Please suggest me

Thanks



#2

[eluser]Aken[/eluser]
Remove the RewriteBase, or take /myapp/ out of the RewriteRule. It should be one or the other. And make sure your .htaccess is in the same spot as your index.php - you should've added a new one there, not modify one already in /application or /system folder.
#3

[eluser]web-johnny[/eluser]
I use in general this htaccess that works everywhere:
Code:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
So in your case just change the:
Code:
RewriteBase /
to:
Code:
RewriteBase /myapp/
and it will work as expected for more you can also check the post at my blog with step by step configuration at: Minimize your URLs at Codeigniter Framework
#4

[eluser]sonu gautam[/eluser]
Thanks for reply i follow your instruction but still it's not working see my upgraded .htacces
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /website_folder/
RewriteCond $1 ^(WebsiteApplication|WebsiteAppFramework|private|logs)
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
RewriteRule ^(.*)$ - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

and my project structure is look like this:

Code:
website_folder -
               - WebsiteAppFramework
               - WebsiteApplication  -
                                     - config
                                     - controllers
                                     - errors
                                     - helpers
                                     - hooks
                                     - language
                                     - libraries
                                     - models
                                     - modules
                                     - views
               - .htaccess

but still i am getting 404 error page.




Theme © iAndrew 2016 - Forum software by © MyBB