Showing posts with label .htaccess. Show all posts
Showing posts with label .htaccess. Show all posts

Wednesday, March 1, 2023

wordpress error 404 when set Permalink structure as Post Name

Hello

I face many time 404 error when I set "Permalink structure" as "Post Name". Here I gave you my solution for this.

Go to your wordpress directory and make .htaccess file and put this code:


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /real611/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /real611/index.php [L]

</IfModule>


Here "real611" is your wordpress folder name. You have to replace it with your wordpress folder name.



Create file "wp.conf" in /etc/apache2/sites-available/wp.conf

by commands, do these steps:-

1. Go to this folder and open terminal from this folder "sites-available" and type this command : sudo vi wp.conf

You will be notifiy for enter password.

2. After entered password, editor is open. Copy paste this code.



<Directory /var/www/html/>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>



3. Now save this file by this commands.

To save a file in Vim / vi, press Esc key, type :w and hit Enter key

One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key





4. Now restart your web server details below:

  1. sudo a2ensite wp.conf
  2. systemctl reload apache2
  3. service apache2 reload
  4. sudo a2enmod rewrite
  5. systemctl restart apache2


Now you can set "Permalink structure" as "Post Name"

Friday, March 4, 2022

CodeIgniter removing index.php from url

 Step:-1 Open the folder “application/config” and open the file “config.php“. find and replace the below code in config.php file.

//find the below code   
$config['index_page'] = "index.php" 
//replace with the below code
$config['index_page'] = ""

Step:-2 Go to your CodeIgniter folder and create .htaccess (inshort in root folder)(dont forget to take backup if .htaccess is already exist.)

Path:
Your_website_folder/
application/
assets/
system/
.htaccess <——— this file
index.php

Step:-3 Write below code in .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

Step:-4 In some case the default setting for uri_protocol does not work properly. To solve this problem just open the file “application/config/config.php“, then find and replace the below code

//Not needed for CodeIgniter 3 its already there.
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI" 
Clear cache and check it without index.php in url