All Questions
5,178 questions
0
votes
0
answers
43
views
PHP-FPM and Apache - setting SCRIPT_NAME
So far as I can tell, a simple installation of Apache and PHP-FPM (the versions supplied in the Debian 12 repository) results in different values for $_SERVER['SCRIPT_NAME'] from when Apache mod_php ...
0
votes
1
answer
41
views
Permission denied: AH00529: /home/username/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
I'm seeing a lot of errors in apache error log:
(13)Permission denied: [client xyz:63932] AH00529:
/home/username/public_html/.htaccess pcfg_openfile: unable to check
htaccess file, ensure it is ...
0
votes
2
answers
32
views
.Htaccess Customize Query String
I am using the code below.
RewriteCond %{QUERY_STRING} ^brands=(.*)&features=(.*)$
RewriteRule ^products/([_A-Za-z0-9-]+)$ index.php?brands=%1&features=%2
However, this requires both values. ...
0
votes
0
answers
23
views
httpd rewrite causing 404 loop
I have taken over an older project that is using Toro to serve routes in a PHP project, and I am having a hard time understanding exactly what it's doing. I believe my issue is in my apache mod ...
0
votes
2
answers
45
views
Apache rewrite engine - Removing PHP extension, getting query string, and appending trailing slash
I recently started working with the rewrite engine and asked for help on removing the PHP extension and adding a trailing slash to URLs. A perfectly working solution was provided by anubhava here. For ...
1
vote
1
answer
99
views
Converting Custom WordPress Pages to Core PHP - Issue with case sensitive URLs
We're currently in the process of migrating custom WordPress pages to core PHP for our website. However, we've encountered an issue related to URL case sensitivity that we're struggling to resolve.
In ...
2
votes
2
answers
80
views
htaccess - rewriting API requests to "api.php" and other requests to "web.php"
I'm testing some stuffs on Apache server and PHP. at the root of my project, I have this
.htaccess configuration file:
RewriteEngine On
RewriteBase /react/
# API requests
RewriteCond %{REQUEST_URI} ^/...
0
votes
0
answers
31
views
Using mod_rewrite to simplify and shorten URL parameter [duplicate]
I'm trying to get the following URL: https://example.com/database?serial_number=XYZ
Turned into https://example.com/database/XYZ
So far everything I have tried either didn't work, created redirect ...
0
votes
0
answers
76
views
404 Error with .htaccess Rewrite Rules on Apache Server
I'm facing an issue with URL rewriting on my Apache server and I'm hoping for some guidance. I'm trying to implement friendly URLs for a REST API, but I keep getting a 404 error.
Setup:
Server: ...
2
votes
2
answers
77
views
mod_rewrite to corresponding php files in subdirectory
I’d like to use mod_rewrite (in .htaccess) to map “clean” URLs to their corresponding php files in a subdirectory, for example:
https://example.com/test/
-->
https://example.com/p/test.php
My ...
1
vote
1
answer
167
views
access pages from wordpress installed in subfolder without the subfolder in url through htaccess [closed]
I have two wordpress installations, one at example.com and another at example.com/landing so what I need to do is to show the page located at example.com/landing/page1 whenever somebody goes to ...
0
votes
0
answers
51
views
CSS not loading despite rewrite rules that should exclude the front controller from files that exist [duplicate]
I am seriously struggling to understand how to achieve what I want in my PHP/HTML and in my .htaccess file.
I want most of my URLs to be handled by index.php unless it's a directory that exists, in ...
0
votes
0
answers
155
views
mod rewriterule for redirect to login session or index page
For OHS (Oracle HTTP Server)/Apache, I am trying to write a Mod rewrite rule
User URL
https://url/console
Target URL
https://url/product/faces/login (If new session)
https://url/product/faces/...
1
vote
1
answer
75
views
How to redirect one URL structure to another url structure?
I need help with htaccess redirect rule.
I've thousands of URL with the structure
https://www.domainname.com/a/b/c/123456 which needs to be redirected to
https://www.domainname.com/a/b/c
But https://...
1
vote
1
answer
31
views
htaccess rewrite some urls but send all others to another page
This is my .htaccess file:
RewriteEngine On
DirectoryIndex index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^login login_reg.php [L] [NC]
...
-1
votes
1
answer
511
views
Apache error.log Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Was getting a 500 Internal Server Error checked the Apache log found this error:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
0
votes
0
answers
26
views
mod_rewrite - how to simplify this rule?
I am quite lame about apache and mod_rewrite, so decided to ask for help.
What I want to achieve?
https://myextrawebsite.com/test.php?page=default¶m1=one¶m2=20¶m3=100&...
0
votes
1
answer
46
views
.htaccess rewrite problem on language path /en/
i have a problem with .htaccess
On localhost it's work its stop on language and redirect good to controler:
http://spa.domain.loc/en/about-us.html
If i try on online live server, i got 404 because ...
2
votes
1
answer
73
views
issues with .htaccess rewrite rules
Having issues with .htaccess rewrite rules. Passing a URL to the browser from users email that includes a token for password reset.
Current .htaccess rules:
Options +FollowSymLinks -MultiViews
...
1
vote
1
answer
34
views
mod_rewrite using QSA,N together
I wrote a mod_rewrite script that removes non-existent folders from any lookup, but passes the folder names to a .php script in an array. The script works as follows:
RewriteEngine On
LogLevel alert ...
2
votes
1
answer
59
views
htcaccess Rewrite Rule not working in any way
I am working on a project and I’m trying to do a URL rewrite in the root of my website. The .htaccess as it is now is as follows
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%...
0
votes
1
answer
20
views
pointing different subdomains to different file in htaccesswhile using wildcard subdomain function
Need help to point main domain to index.php and subdomains to its own file in htaccess while using wildcard subdomain function
for example:
test.com to index.php
ru.test.com to ru.php
de.test.com to ...
1
vote
1
answer
45
views
Redirect using htaccess using a slash, underscore or dates as separators - friendly urls
This works fine:
https://example.com/2023/not-the-dinner-day
Using the following RewiteRule
RewriteRule ^(\d{4})/not-the-dinner-day/?$ archive/reports/$1/ntdd.php [NC,L]
I want to get this new URL:
...
1
vote
2
answers
399
views
symony apache htaccess how to lose the /public/ from route?
I have symfony 6 and apache pack is installed. Nothing changes when I run recipes:update so I understand apache pack is updated (and has placed .htaccess files for me?).
The route to my site is still ...
0
votes
0
answers
34
views
Rewriting and redirecting URL with htaccess
First time doing the URL rewrite using .htaccess using XAMPP and seen other post here somewhere similar. This post provide me enough ideas URL rewriting with PHP but for some reason my attempt failed.
...
0
votes
0
answers
176
views
Apache rewrite rule not preserving POST data
I have an UBUNTU server with Apache. POST request to specific endpoint on this server is automatically redirected by Apache to a GET request if the URL does not have a trailing slash
On that path, the ...
0
votes
1
answer
150
views
I am getting 500 error when I use trailing slash
I am getting 500 error when I put trailing slash with any of the url but homepage. I tried to follow one of the posts from Stack Overflow community but unable to understand how I can follow for my ....
1
vote
1
answer
138
views
htaccess php file first and then folder
I am using the above in my .htaccess file
# BEGIN - Allow Sucuri Services
<IfModule mod_rewrite.c>
RewriteRule ^sucuri-(.*)\.php$ - [L]
</IfModule>
# END - Allow Sucuri Services
<...
0
votes
1
answer
65
views
htaccess RewriteRule only root page proxy to another page
I need to show on home page (root page) content of another page.
The easiest way is RewriteRule proxy, I think.
If I need to show page /abc/ at uri /test/ next rule works:
RewriteCond %{REQUEST_URI} ^/...
1
vote
1
answer
38
views
.htaccess RewriteRule not redirecting files, only directories
I've been trying to get an .htaccess RewriteRule working for the past few days with no success. On the server I am working from, there is a website which allows uploads. The uploads are stored in ...
-2
votes
1
answer
334
views
why url with slash gives 404 error on website?
I want URL with slash / at the end.
On my website if I the enter URL with slash / at the end it is giving 404 error.
I modified .htaccess file with the below code. Still not working.
AcceptPathInfo ...
1
vote
1
answer
1k
views
Rewrite URL to a directory to a PHP file using htaccess
I am trying to do a simple rewrite rule using an htaccess file. I have this page hosted on localhost using XAMPP:
localhost/naveesh/services.php
A possible way to request this is like this:
localhost/...
3
votes
0
answers
2k
views
.htaccess rewrite space in URL returns 403 Forbidden error
I have PHP application, on Ubuntu Apache web server.
Application have search feature, as GET type of request.
After submitting search string, Apache returns 403 Forbidden error, if I have more that ...
1
vote
0
answers
68
views
Is it possible to use both XSendFile and mod_rewrite (with relative paths)?
I'm getting a puzzling error when using XSendFile and mod_rewrite.
XSendFile works properly when serving a file from a PHP script without a rewritten URL, but breaks causing a 404 error when a URL ...
2
votes
3
answers
1k
views
.htaccess redirect www to non-www but not doing anything
If I go to https://example.com, then everything is working fine. However if I go to https://www.example.com, then none of my static files load because it says that it goes against the CSP. Thus, I'm ...
0
votes
0
answers
310
views
htaccess Replace all special characters in query string
I have a URL like below:
https://example.com/en/search/result?keys=test"><script>alert('helloworld')</script>
I need to replace special characters with their respective URL ...
2
votes
2
answers
113
views
htaccess infinite loop issue
I have run into an issue with my .htaccess file.
The file changes the ugly URL such as http://localhost/news.php?article_slug=example-1 to http://localhost/news/example-1
This works perfectly, but ...
1
vote
1
answer
85
views
PHP GET after htaccsess rewrite
I am trying to get the variable from my url but having problems.
the default URL is http://localhost/category.php?category_slug=gaming
With my htaccsess file
RewriteRule ^category/([\w\d-]+)$ /...
1
vote
1
answer
724
views
Apache Redirect /api Requests To Directory
I come from a C# MVC background but I am currently working on a PHP project.
In C# you can setup decorators to specify the request URL using something along these lines:
[HttpGet]
[Route("/...
0
votes
1
answer
333
views
NOSTR NIP-05 Send get request parameter to a json file and return an appropriate response
NIP-05 Mapping Nostr keys to DNS-based internet identifiers describes a requirement to be able to handle GET requests to a .json file. For obvious security reason I want to return a json only if ...
1
vote
1
answer
226
views
How to fix: RewriteRule not working in .htaccess
Please consider the content in my .htaccess:
##
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
## Allow a few SEO Files direct access.
RewriteRule ^robots.txt?$ robots.txt [L]
...
1
vote
1
answer
32
views
.htaccess Rewrite last five directories as GET values
I have the following URL:
https://sub.example.com/economy/billing/payment-check/434/khipu/1000/CLP/1673526088/
I want the last 5 directories to be converted to GET values, to reflect the following URL:...
1
vote
1
answer
104
views
Remove ?id= in php using .htacess
I am trying to remove ?id= from the URL and replace ?id= with a slash (/).
I want to show the address:
http://localhost/new/view-seller?id=534f5ddbdd
As:
http://localhost/new/view-seller/534f5ddbdd
...
1
vote
1
answer
131
views
htaccess redirect single Wordpress page to new no-Wordpress page
For a project where I converted an old Wordpress environment to a non-Wordpress environment, I need a redirect of one specific Wordpress page.
For example:
Old (WordPress page)
https://www.example.com/...
0
votes
1
answer
161
views
Serve cache via apache/htaccess, if file exists, otherwise load data from database
I found this question:
Serve file from cache folder if it exists, otherwise rewrite to "index.php" using .htaccess
and it was useful but i'm not able to write code for my system.
This is ...
1
vote
1
answer
426
views
htaccess redirect to https not working in codeigniter 3
I found a lot of similar answers but so far I could not solve the right thing that I want. It seems very easy or maybe somebody already answered but for me it's not working.
I've solved redirect to ...
0
votes
1
answer
1k
views
ErrorDocument 404 .htaccess not working with RewriteRule
.htaccess ErrorDocument 404 page not redirecting when I was using the rewrite rule. Getting 500 Internal Server Error.
Without RewriteRule the ErrorDocument is Working fine.
My Code
RewriteEngine ...
1
vote
1
answer
117
views
URL Rewrite removes last parameter without trailing slash
I'm trying mod_rewrite through .htaccess in Apache server. My folder structure is as below:
- www/myproject/
- api/
- index.php
- api-controllers/
- css/
- js/
index.php
....
0
votes
1
answer
45
views
mod_rewrite works fine on linux but returns forbidden on windows 10
I'm working with wampserver on windows 10 for local development.
after that i made my script live and it works fine but after some days i implemented url rewrite.
my scipts works fine on live server.
...
0
votes
2
answers
117
views
How to get .htaccess to return 404 instead of 500 for missing files
Background
I am building a PHP application that uses MVC principles. I am not every experienced in writing .htaccess files, but I have a solution that works very well for my application. All requests ...