regex


Configuring mod_rewrite issue


I have in my htaccess the following:
DirectoryIndex index.py
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)$ index.py?id=$1 [L]
RewriteCond %{THE_REQUEST} /index\.py [NC]
RewriteRule ^(.*?)index\.py$ /$1 [L,R=302,NC,NE]
First rule sends someone looking for
mydomain.com/<digits>
to mydomain.com/index.php?id=, second rule fixes hrefs inside index.py.
But when I add
RewriteBase /
RewriteRule ^([^0-9]+)$ index.py [L]
To make anyone whose request is not only digits go to index.py, divs in index.py just kinda disappear. What is the problem?
Probably because you're rewriting everything to index.py, including your style sheets or scripts or whatever. Try changing the rule to:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^0-9]+)$ index.py [L]

Related Links

how can I use a wildcard in restify routes
Regex - unknown place of character
Regex Replace 406 with 401
Replace string with another string based on backreference in bash
D: split string by comma, but not quoted string
move a pattern to the beginning of a line with sed
Need a modification in the regular expression
regular expression matching string in scala
Why is C#'s Regex.Matches() returning all matches in a single Match object?
From Matlab to R: Capture named fields with regular expressions to a dataframe
How can I find repeated words in a file using grep/egrep?
Pattern match with stored variable or regular expression in Bash
Regexp matching of “a*” in expect
grep to match a certain number sequence in a mix of text and numbers
Bash sed - find hashtags in string
Python & Regex: Match all, but not when x or y

Categories

HOME
ios
performance
logstash
google-apis-explorer
angular2-forms
openshift-origin
direction
haskell-stack
styling
prometheus
api.ai
open-source
android-sms
restsharp
apple-mail
r-caret
tin-can-api
windows-10-desktop
identifier
wav
pymc3
rebus
android-dialogfragment
phpbb3
prerender
countdown
servlet-filters
netcdf
jqplot
slf4j
italic
jtable
google-geocoder
kube-dns
complex-networks
ose
spring-data-cassandra
increment
nio
disqus
qweb
vue2
extjs4
uitabbarcontroller
dxgi
angular2-seed
angularjs-routing
program-slicing
ase
default-browser
move
uifont
master-data-management
gpt
tastypie
breach-attack
wxhaskell
configuration-profile
hard-drive-failure
vispy
xnamespace
sqlfiddle
xmllint
network-traffic
mars
multiple-files
genetic
uikeyboard
interpreted-language
translate3d
cbc-mode
antiforgerytoken
mks
isql
slick2d
mpj-express
laravel-validation
formhelper
mui
lwuit-list
iqueryable
controlsfx
bunny
tinkerpop-frames
deepzoom
azimuth
xsltforms
disk-io
modalpopupextender
sshj
appstore-sandbox
ioerror
xhtml-transitional
double-precision
dependency-walker
ria
proxy-classes
payment-services
android-assets
demoscene
textboxlist
jquery-pagination
nstreecontroller
excel-web-query
project-settings
code-statistics

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App