Note: That
RewriteCond %{REQUEST_FILENAME} !-d
is absent from the rule.My intention: is to return 404 for all request not looking for an existing file. Thus negating access to directories too. I don’t want public to peek through directory structure.
My concern: is that this rule, which also deny access to directories, could potentially disrupt WordPress functionality or usage.
# /wordpress/.htaccess
<IfModule mod_rewrite.c>
# return 404 for all request not looking for an existing file
RewriteCond %{REQUEST_URI} ^/wordpress/(wp-content|wp-includes)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [R=404,L]
</IfModule>
]]>I’m using Apache but my current PHP version runs as php-fpm and I guess that’s the reason, why WordPress is showing me in my permalinks configuration on /wp-admin/options-permalink.php
links like:
https://contoso.com/index.php/2023/11/28/example-post/
So including “index.php”, which I really don’t need.
I figured out that’s because got_url_rewrite() | Function | WordPress Developer Resources returns false in this case, and that’s because apache_mod_loaded() | Function | WordPress Developer Resources returns false (detects not apache).
How do you deal with this issue? How can I tell WordPress, that my php-fpm based website has mod_rewrite in fact and I don’t need this “index.php” in the permalinks?
Thank you in advance
I was thrilled yesterday to export them all back to .htaccess. Thank you thank you for this export ability! Every complex regex worked like a charm!
]]>My review is still a 1 start as I think it’s very poor that you did not fix an issue that has been known for 5 years. It’s not user friendly and for me that what WP is all about.
Note that I’ll be more than happy to change my review once it has been fixed.
]]>I have taken the time to study how mod_rewrite works and I more or less get it. But I do not understand what is the working relationship between mod_rewrite and wordpress.
I get that wordpress uses PHP to look into the database to “construct” the “requested” URL. Makes perfect sense and I have written PHP to do it outside of wordpress. But since wordpress constructs the URL I don’t see why it even needs mod_rewrite. It could store in the database the URL format setting and use PHP code to create the Plain or Post name URL.
So just what happens internally when I switch from Plain to Post name in the Dashboard? And, again, why does wordpress need mod_rewrite?
Sunny
]]>I am trying to get WordPress working on my Raspberry Pi. I just installed the latest version with Apache2. It seems to work, but only if I have the Permalink settings at “Simple.” Anything else gives me the “Updating failed. Error message: The response is not a valid JSON response.” Or a web page “Not Found” if I try to preview my change. Thanks for you help,
>>>Steve<<<
]]>https://county.asystyoutech.net/business-directory/25/administration/
to this:
https://county.asystyoutech.net/departments/administration/
Here is my RewriteCond and RewriteRule:
RewriteCond %{HTTP_HOST} website.com
RewriteRule ^business-directory/.*?/(.*?)(/.+?)?$ /departments/$1$2
I have the rule added to httpd-app.conf
I am logging the rewrite_mod output to my error_log in apache. I am monitoring the log file as I hit URLs on my site that need re-writing. I can see where the pattern from my rule is applied but nothing else happens after the application. Here is an excerpt from the log file.
applying pattern ‘^business-directory/.?/(.?)(/.+?)?$’ to uri ‘wp-content/plugins/business-directory-plugin/assets/css/dnd-upload.min.css’, referer: https://county.asystyoutech.net/business-directory/54/building-inspector/
pass through /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/business-directory-plugin/assets/css/dnd-upload.min.css, referer: https://county.asystyoutech.net/business-directory/54/building-inspector/
strip per-dir prefix: /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css -> wp-content/plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css, referer: https://county.asystyoutech.net/business-directory/54/building-inspector/
applying pattern ‘^index\.php$’ to uri ‘wp-content/plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css’, referer: https://county.asystyoutech.net/business-directory/54/building-inspector/
strip per-dir prefix: /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css -> wp-content/plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css, referer: https://county.asystyoutech.net/business-directory/54/building-inspector/
I am testing the rewrite rule with this tool and the output is what I am expecting.
https://htaccess.madewithlove.be?share=e001da82-cf80-54a6-a34a-e943f1519700
I have searched through everything I can find on this topic specific to apache and wordpress but haven’t found anything that gets me closer to a solution. Any suggestions on what might be wrong?
I have posted this to the Bitnami support forum and they directed me to post here and see if someone on the WordPress forum could offer help.
]]>Apart from WP Super Cache complaining that it can’t update the mod_rewrite rules, the cache appears to be working just fine – page source shows “<!– Cached page generated by WP-Super-Cache on 2019-09-06 07:14:17 –>”.
My question is, has anyone else configured WP Super Cache in the same way and is there any downside to doing so?
Many thanks, Steve.
]]>I would like the post post_type (https://www.instrumentrentalbarcelona.com/?post_type=post) to display if someone goes to https://www.instrumentrentalbarcelona.com/blog. I have created rewrite in .htaccess and it is redirecting to /blog however it is giving me a 404.
This is it including the rest of my rewrites:
#Single URL Rewrite
RewriteCond %{QUERY_STRING} ^post_type=post$
RewriteRule ^$ /blog [QSD,R,L]
#http www rewrite
RewriteCond %{HTTP_HOST} ^instrumentrentalbarcelona.com [NC]
RewriteRule ^(.*)$ https://www.instrumentrentalbarcelona.com/$1 [L,R=301,NC]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is what you see when you go to the post post_type: https://www.screencast.com/t/ofJlpsGN6fNb (currently redirects to /blog and shows 404)
Probably something real simple. Any advice would be greatly appreciated?
Best,
Sascha