I have this wildcard route:
$route['izvlacenje-2022/(:any)']['GET'] = 'WinnersController/draw_screen/$1';
that works fine locally, but not on the server in the staging sub-folder where it gives me 404 error:
http://project.localhost/izvlacenje-2022/renovate // works fine locally
https://our-domain/staging/izvlacenje-2022/renovate // does not work in staging folder, gives 404
Other, non wildcard routes work fine. For example:
$route['intro']['GET'] = 'LandingsController/index';
https://our-domain/staging/intro // works fine
httacces:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /staging
RewriteCond $1 !^(index\.php|resources|gallery|json|slider|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
Also, in the config file I set the index_page value to blank, but it does not work either way:
$config['index_page'] = '';
Related
I used ajax to Load pagination content in its frame. Everything was OK in Local host. For example in http://localhost:8000/exampleroute pagination link for comments section , page 2 is: http://localhost:8000/content/page_comments?page=2 and works well.
But in shared host is: https://example.com/content/page_comments?%2Fexampleroute=&page=2 and links not work.
I guess the problem is related to .htaccess file. so .htaccess contents here:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
What is base problem?
RewriteBase / seems like it could be the issue.
Remove it and compare against https://laravel.com/docs/5.6/installation#pretty-urls. Make sure in your .env file you have APP_URL value set to your application url.
I have some problem. In development I'm using php 7 and my website work well. But in production it using php 5.4 and I have problem in removing index.php. My website hosted in subfolder just like myhost/mywebsitefolder.
The problem is when using url function. example, when I accesing 'dashboard' page it will redirect to 'login' page and the url is like myhost/mywebsitefolder/login and it return 404 page not found. When I add index.php before login (myhost/mywebsitefolder/index.php/login) it work well but I must replace all of my url by adding index.php. Are there any solution. My .htaccess is just like this.
RewriteEngine on
RewriteBase /mywebsitefolder/
RewriteCond $1 !^(index.php|resources|gallery|json|slider|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Try with a slash before the dots, like:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /mywebsitefolder
RewriteCond $1 !^(index\.php|resources|gallery|json|slider|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
And in application/config/config.php and clear the index page config value:
// Old
$config['index_page'] = "index.php";
// New
$config['index_page'] = "";
Sometimes you need to enable it the rewrite module, run "apache2 enable module rewrite":
sudo a2enmod rewrite
You need to restart the webserver to apply the changes:
sudo service apache2 restart
Hope it works!
If no, there is others threads with the same problem,you can take a look:
- Remove index.php from codeigniter in subfolder
- Remove index.php from Codeigniter URL in subfolder with Wordpress in root
- Using htaccess to remove codeigniter index.php in a subdirectory
I would like to have a multilingual website but I haven't finished english version yet so I would like to redirect if url has /en/ to a specific page with a content "Soon". This page would be www.sitename.com/en/welcome
I am doing this in Wordpress and I don't know .htaccess that good. This code actually works pretty good, it checks for language set and redirects accordingly, but the problem is that after visiting that url I want to go to www.sitename.com, it still redirects me to that page (probably since locale doesn't change).
add_action("template_redirect", 'pl_redirect');
function pl_redirect() {
// if is english redirect to page id 193
if (get_locale() == 'en_US' && !is_page(193)){
wp_redirect( 'http://www.sitename.com/en/welcome' );
exit;
}
}
How can I accomplish the same thing correctly?
I tried this in .htaccess but it doesn't work
Options +FollowSymLinks
RewriteEngine on
Redirect 301 ^/en/$ /en/welcome
This is by Wordpress inside .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php [L]
RewriteRule ^/en/$ /en/welcome [R=301]
</IfModule>
Assuming you have actually installed everything in a directory called /web - you'll need 2 .htaccess files:
/.htaccess (the root WordPress .htaccess file)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# the base directory
RewriteBase /web/
# this means "don't rewrite /web/index.php"
RewriteRule ^index\.php$ - [L]
# this is a router any URL that's neither a file
# nor a directory will be routed to /web/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php [L]
</IfModule>
/web/.htaccess (your rewrite)
RewriteEngine On
RewriteRule ^en/?$ /web/en/welcome [NC,L,R=302]
I am working on a project in which url Rewriting was done.
Here is the link of the old uri
http://www.mysite.pk/jobs/search/faisalabad/all-cats
But now in the new url I have changed it to
http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats
what I want to do is to change the redirect all the url's whcih have http://www.mysite.pk/jobs/search/ search after job in them to the
http://www.mysite.pk/jobs/pakistan/
Here is my code of the route
$route["jobs/pakistan"]="vacancies/search";
If you have any other solution then .htaccess kindly share it.
.htaccess file use for remove index.php from base url following codes in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Rest your code are correct in route same
$route["jobs/pakistan"]="vacancies/search";
$route["Link You Want"]="Actual path to access";
So, today I upgrade PHP and apache on my server to version PHP 5.4 and Apache 2.4.
And then I noticed on one domain using older version of codeigniter (I've try to echo CI_VERSION but it shows nothing) is showing error 404 on the root domain. But typing domain.com/home works fine. (home is my default controller). Typing any other controller also working fine. But domain.com shown error 404.
.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|apc\.php|assets|nivo-slider|hr|stm|elearning|docs|adminer|favicon\.ico|file|flash|tinymce|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /application/errors/404.php
</IfModule>
config.php
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
routes.php
$route["default_controller"] = "home";
$route["error_controller"] = "error";
$route['scaffolding_trigger'] = "";
I've trying change uri_protocol to QUERY_STRING & REQUEST_URI but still not working.
I managed to solve this problem by adding DirectoryIndex home on my .htaccess.