3

I'm trying to post a question on Stack Overflow, but I got the following error message:

Please add some context to explain the code sections (or check that you have not incorrectly formatted all of your question as code).

Here is an attempt to post in text therefore, with formatting removed:


Title:

.htaccess fail- using RewriteCond to make exception to file extension-removal snippet - posted in text


this is a .php file extension removal snippet, for displaying links online. RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+).php [NC]
RewriteRule ^ %1 [R,L]

this is where i make the exception

RewriteCond %{REQUEST_FILENAME} !^/PhP/?$  
RewriteCond %{REQUEST_FILENAME} !^/forms/?$  
RewriteCond %{REQUEST_URI} !^/PhP/?$  
RewriteCond %{REQUEST_URI} !^/forms/?$  

this is original snippet

RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME}.php -f  
RewriteRule ^(.*?)/?$ $1.php [L]  

in this snippet, I want to exclude two directories- PhP & forms- as the snippet is apparently preventing me from database access, as all connect & config files lie in those directories- however, the above example is ineffective. the four Rewrite Cond in the middle section above, are attempting to make the exceptions, followed by (last 3 lines) the original snippet code. What am I doing wrong? Thanks in advance

7
  • 4
    From the first version of the post, it seems that you were actually trying to post this in the right place. I'll try to restore that...
    – Glorfindel Mod
    Commented Jan 9, 2020 at 15:20
  • much appreciated. dead in the water until this programming issue is solved- im
    – imsimpl
    Commented Jan 9, 2020 at 21:31
  • I suspect with a few more details, this might work better on serverfault than SO - I'm guessing apache but you need to make it explicit what webserver.
    – Journeyman Geek Mod
    Commented Jan 10, 2020 at 3:20
  • @imsimpl If you want a technical answer to the question you were unable to post, this is the wrong place. You should definitely improve your post and post it on Stack Overflow
    – Luuklag
    Commented Jan 10, 2020 at 15:46
  • 3
    @Luuklag the reason you are even seeing this post is, because i first ATTEMPTED to post it on Stack Overflow, and the post somehow got bounced to here.
    – imsimpl
    Commented Jan 10, 2020 at 16:08
  • 1
    Once again, this isn't the place you will get a technical answer to your question. Post it on SO, you have been given guidance on what might cause the rejection of your post, and include the clarifications you were trying to add here. That would make for an OK question I think, although I'm no subject matter expert.
    – Luuklag
    Commented Jan 10, 2020 at 18:58
  • 1
    Let me add a bit more detail: this site, Meta Stack Exchange, is for discussions, bug reports, and feature requests about the Stack Exchange network of Q&A sites. Unfortunately, the programming issue you're asking about is off-topic for this site, per the above link. The fact that you can't post on the proper site doesn't make it on-topic here. Users here have provided some guidance on how to work around those issues and get your question posted on Stack Overflow; if you want your programming question answered, you must follow those tips and post there. Commented Jan 10, 2020 at 19:37

1 Answer 1

10

The problem is probably in this part:

this is a .php file extension removal snippet, for displaying links online. RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+).php [NC]
RewriteRule ^ %1 [R,L]

You need a blank line before a code block, like you did for the other snippets:

this is a .php file extension removal snippet, for displaying links online.

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]  
    RewriteRule ^ %1 [R,L]  

That would produce

this is a .php file extension removal snippet, for displaying links online.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]  
RewriteRule ^ %1 [R,L]  
3
  • This is Meta; not the right place to answer technical programming questions. OP was asking about the validity of the question.
    – ndugger
    Commented Jan 9, 2020 at 16:37
  • 28
    No, they were not asking a programming question, they were asking why they couldn't ask a programming question. That makes it a Meta question (probably more at home on Meta Stack Overflow, but not necessarily off-topic here).
    – Glorfindel Mod
    Commented Jan 9, 2020 at 16:42
  • 7
    It's definitely on-topic here. The code filter in question is enabled on multiple sites. Commented Jan 10, 2020 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .