LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-23-2024, 07:46 AM   #1
lq_win
Member
 
Registered: Jul 2015
Posts: 66

Rep: Reputation: Disabled
mod_rewrite or .htaccess not working


Hi There,

I have enabled mod_rewrite and make sure the following:

httpd -M | grep rewrite
rewrite_module (shared)

and my .htaccess in /var/www/html/test

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

current condition:

when I browse to https://apps.example.com/test --> it goes to https://apps.example.com/test/auth/login and returns 404

what I missed?
 
Old 04-23-2024, 08:48 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
The mistake is putting the rewrite rules into an .htaccess file instead of the main configuration file. The .htaccess setup is a leftover from a kind of shared hosting common in the mid to late 1990s and usually not relevant these days. Put your rewrite rules in the main configuration file, which will likely be somewhere under /etc/apache2/sites-available/

Then the following will deploy the changes, assuming there are no syntax errors:

Code:
apache2ctl configtest && apache2ctl graceful
However, even without syntax errors the rules may still need some revision to do what you actually want them to do.

As for the debugging of the rules, is /var/www/html/test/ a directory or is /var/www/html/test a file?
 
Old 04-24-2024, 11:02 AM   #3
lq_win
Member
 
Registered: Jul 2015
Posts: 66

Original Poster
Rep: Reputation: Disabled
[root@apps ~]# apachectl configtest && apachectl graceful
Syntax OK

/var/www/html/test/ a directory
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mod_rewrite htaccess not working konzo Linux - Server 2 11-25-2010 04:16 AM
LXer: Subdomain Redirection Using htaccess And mod_rewrite On Apache For Linux Or Uni LXer Syndicated Linux News 0 02-27-2009 09:00 AM
.htaccess - how do I strip characters from a dynamic url? using Mod_rewrite kilaz Linux - Server 3 10-15-2008 12:28 PM
.htaccess mod_rewrite issue Jukas Linux - Software 2 12-13-2005 12:23 PM
Suse 9.1 Pro & htaccess file: mod_rewrite not loading sorenson2743 SUSE / openSUSE 2 12-03-2004 11:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration